Verified Commit de839e1e authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3306208 by Spokje, quietone: Deprecate farbtastic in 9.5.x

parent 39aa6200
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -780,6 +780,7 @@ jquery.farbtastic:
      assets/vendor/farbtastic/farbtastic.css: {}
  dependencies:
    - core/jquery
  deprecated: The %library_id% asset library is deprecated in Drupal 9.5.0 and will be removed in Drupal 10.0.0. There is no replacement. See https://www.drupal.org/node/3306232

internal.jquery.form:
  # Internal library. Do not depend on it outside core nor add new core usage.
+10 −10
Original line number Diff line number Diff line
@@ -963,24 +963,24 @@ function hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAss
 * @see \Drupal\Core\Asset\LibraryDiscoveryParser::parseLibraryInfo()
 */
function hook_library_info_alter(&$libraries, $extension) {
  // Update Farbtastic to version 2.0.
  if ($extension == 'core' && isset($libraries['jquery.farbtastic'])) {
  // Update imaginary library 'foo' to version 2.0.
  if ($extension === 'core' && isset($libraries['foo'])) {
    // Verify existing version is older than the one we are updating to.
    if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) {
      // Update the existing Farbtastic to version 2.0.
      $libraries['jquery.farbtastic']['version'] = '2.0';
    if (version_compare($libraries['foo']['version'], '2.0', '<')) {
      // Update the existing 'foo' to version 2.0.
      $libraries['foo']['version'] = '2.0';
      // To accurately replace library files, the order of files and the options
      // of each file have to be retained; e.g., like this:
      $old_path = 'assets/vendor/farbtastic';
      $old_path = 'assets/vendor/foo';
      // Since the replaced library files are no longer located in a directory
      // relative to the original extension, specify an absolute path (relative
      // to DRUPAL_ROOT / base_path()) to the new location.
      $new_path = '/' . \Drupal::service('extension.list.module')->getPath('farbtastic_update') . '/js';
      $new_path = '/' . \Drupal::service('extension.list.module')->getPath('foo_update') . '/js';
      $new_js = [];
      $replacements = [
        $old_path . '/farbtastic.js' => $new_path . '/farbtastic-2.0.js',
        $old_path . '/foo.js' => $new_path . '/foo-2.0.js',
      ];
      foreach ($libraries['jquery.farbtastic']['js'] as $source => $options) {
      foreach ($libraries['foo']['js'] as $source => $options) {
        if (isset($replacements[$source])) {
          $new_js[$replacements[$source]] = $options;
        }
@@ -988,7 +988,7 @@ function hook_library_info_alter(&$libraries, $extension) {
          $new_js[$source] = $options;
        }
      }
      $libraries['jquery.farbtastic']['js'] = $new_js;
      $libraries['foo']['js'] = $new_js;
    }
  }
}
+2 −7
Original line number Diff line number Diff line
jquery.farbtastic:
popperjs:
  version: 0.1
  js:
    assets/vendor/farbtastic/farbtastic.js: {}
  css:
    component:
      assets/vendor/farbtastic/farbtastic.css: {}
  dependencies:
    - core/jquery
    assets/vendor/popperjs/popper.min.js: { }

# Library to test CSS and JS file assets.
files:
+6 −6
Original line number Diff line number Diff line
@@ -170,15 +170,15 @@ function common_test_library_info_build() {
 * Implements hook_library_info_alter().
 */
function common_test_library_info_alter(&$libraries, $module) {
  if ($module == 'core' && isset($libraries['jquery.farbtastic'])) {
    // Change the version of Farbtastic to 0.0.
    $libraries['jquery.farbtastic']['version'] = '0.0';
    // Make Farbtastic depend on jQuery Form to test library dependencies.
    $libraries['jquery.farbtastic']['dependencies'][] = 'core/internal.jquery.form';
  if ($module === 'core' && isset($libraries['popperjs'])) {
    // Change the version of Popper to 0.0.
    $libraries['popperjs']['version'] = '0.0';
    // Make Popper depend on jQuery Form to test library dependencies.
    $libraries['popperjs']['dependencies'][] = 'core/internal.jquery.form';
  }

  // Alter the dynamically registered library definition.
  if ($module == 'common_test' && isset($libraries['dynamic_library'])) {
  if ($module === 'common_test' && isset($libraries['dynamic_library'])) {
    $libraries['dynamic_library']['dependencies'] = [
      'core/jquery',
    ];
+3 −4
Original line number Diff line number Diff line
@@ -11,10 +11,9 @@ libraries-override:
  core/drupal.dialog:
    js:
      misc/dialog/dialog.js: false
  core/jquery.farbtastic:
    css:
      component:
        assets/vendor/farbtastic/farbtastic.css: css/farbtastic.css
  core/popperjs:
    js:
      assets/vendor/popperjs/popper.min.js: js/popper.min.js
  theme_test/theme_stylesheets_override_and_remove_test:
    css:
      base:
Loading