diff --git a/core/core.libraries.yml b/core/core.libraries.yml index 21e7989125ed6b0646493b350198402dc22f52d2..e79d13db32269e82914d374f643125b5df224fce 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -1,6 +1,24 @@ # All libraries are defined in alphabetical order. backbone: + remote: https://github.com/jashkenas/backbone + version: "1.4.0" + license: + name: MIT + url: https://raw.githubusercontent.com/jashkenas/backbone/1.4.0/LICENSE + gpl-compatible: true + js: + assets/vendor/backbone/backbone-min.js: { weight: -19, minified: true } + dependencies: + - core/underscore + deprecated: The %library_id% asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. + +internal.backbone: + # Internal library. Do not depend on it outside core nor add new core usage. + # The library will be removed as soon as the following issues are fixed: + # - https://www.drupal.org/project/drupal/issues/3203920 + # - https://www.drupal.org/project/drupal/issues/3204011 + # - https://www.drupal.org/project/drupal/issues/3204015 remote: https://github.com/jashkenas/backbone version: "1.4.0" license: @@ -1085,7 +1103,7 @@ underscore: deprecated: The %library_id% asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0. internal.underscore: - # Internal library, do not depend on it. + # Internal library. Do not depend on it outside core nor add new core usage. # The library will be removed as soon as the following issues are fixed: # - https://www.drupal.org/project/drupal/issues/3270395 # - https://www.drupal.org/project/drupal/issues/3203920 diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index ec254499ba25fc2a15900741fc122dc8190c24a5..dccd37777884a8ee5b0b8553cd6de7bf03f4f287 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -844,7 +844,7 @@ function hook_library_info_build() { // Add a library whose information changes depending on certain conditions. $libraries['mymodule.zombie'] = [ 'dependencies' => [ - 'core/backbone', + 'core/once', ], ]; if (Drupal::moduleHandler()->moduleExists('minifyzombies')) { diff --git a/core/modules/ckeditor/ckeditor.libraries.yml b/core/modules/ckeditor/ckeditor.libraries.yml index 48bb5e473576db34ae35c0cce5b57c64ec1f8006..7c6fc2f933b55154c58c1c1a1473f3a548bfd4e7 100644 --- a/core/modules/ckeditor/ckeditor.libraries.yml +++ b/core/modules/ckeditor/ckeditor.libraries.yml @@ -50,7 +50,7 @@ drupal.ckeditor.admin: - core/drupal - core/drupalSettings - core/once - - core/backbone + - core/internal.backbone - core/drupal.dialog - core/drupal.announce - core/ckeditor diff --git a/core/modules/contextual/contextual.libraries.yml b/core/modules/contextual/contextual.libraries.yml index 3a5918f7e15532fb029cf77ec8e8164856600ae2..0a0117be00b8ba282c21746b8d351c09d6825f4d 100644 --- a/core/modules/contextual/contextual.libraries.yml +++ b/core/modules/contextual/contextual.libraries.yml @@ -22,7 +22,8 @@ drupal.contextual-links: - core/drupal - core/drupal.ajax - core/drupalSettings - - core/backbone + # @todo Remove this in https://www.drupal.org/project/drupal/issues/3203920 + - core/internal.backbone - core/modernizr - core/once @@ -41,7 +42,8 @@ drupal.contextual-toolbar: dependencies: - core/jquery - core/drupal - - core/backbone + # @todo Remove this in https://www.drupal.org/project/drupal/issues/3203920 + - core/internal.backbone - core/once - core/drupal.tabbingmanager - core/drupal.announce diff --git a/core/modules/quickedit/quickedit.libraries.yml b/core/modules/quickedit/quickedit.libraries.yml index 60cb2f6d4bbc06df3265df2cdd11afbe0bf0ed19..cb5813927a0d3521ca240619b85abb6271ce83f0 100644 --- a/core/modules/quickedit/quickedit.libraries.yml +++ b/core/modules/quickedit/quickedit.libraries.yml @@ -30,7 +30,7 @@ quickedit: - core/jquery - core/once - core/internal.underscore - - core/backbone + - core/internal.backbone - core/jquery.form - core/drupal - core/drupal.displace diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index 620a19639dfd9fab4d19303e5d37f7ad11b94d2c..2e88a4abfb47c478e4e0cf9b5d141fe7b4e24b5f 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -153,7 +153,7 @@ function theme_test_system_info_alter(array &$info, Extension $file, $type) { if ($type == 'theme' && $file->getName() == 'test_theme' && \Drupal::state()->get('theme_test.modify_info_files')) { // Add a library to see if the system picks it up. $info += ['libraries' => []]; - $info['libraries'][] = 'core/backbone'; + $info['libraries'][] = 'core/once'; } } diff --git a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php index 64b9b87bde7521f402e7fc024803311cc41d2776..93242b6d8ebadef25870885a9431ea86de69a60a 100644 --- a/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php +++ b/core/modules/system/tests/src/Functional/Theme/ThemeInfoTest.php @@ -101,7 +101,7 @@ public function testChanges() { $this->state->set('theme_test.modify_info_files', TRUE); $this->resetAll(); $active_theme = $this->themeManager->getActiveTheme(); - $this->assertEquals(['classy/base', 'classy/messages', 'core/normalize', 'test_theme/global-styling', 'core/backbone'], $active_theme->getLibraries()); + $this->assertEquals(['classy/base', 'classy/messages', 'core/normalize', 'test_theme/global-styling', 'core/once'], $active_theme->getLibraries()); } } diff --git a/core/modules/toolbar/toolbar.libraries.yml b/core/modules/toolbar/toolbar.libraries.yml index d8140142d704365781eb9adbc21e0eb0455e53d8..eee3f4e2430cd5ec660c66984377b427e5377f5c 100644 --- a/core/modules/toolbar/toolbar.libraries.yml +++ b/core/modules/toolbar/toolbar.libraries.yml @@ -24,7 +24,8 @@ toolbar: - core/drupalSettings - core/drupal.ajax - core/drupal.announce - - core/backbone + # @todo Remove this in https://www.drupal.org/project/drupal/issues/3204015 + - core/internal.backbone - core/once - core/drupal.displace - toolbar/toolbar.menu diff --git a/core/modules/tour/tour.libraries.yml b/core/modules/tour/tour.libraries.yml index f8f717b019f3bf392cdface2034a623e34898402..224370522c616368992778c53daf184d3ef9ad50 100644 --- a/core/modules/tour/tour.libraries.yml +++ b/core/modules/tour/tour.libraries.yml @@ -6,7 +6,8 @@ tour: - core/jquery - core/once - core/drupal - - core/backbone + # @todo Remove this in https://www.drupal.org/project/drupal/issues/3204011 + - core/internal.backbone - core/shepherd - tour/tour-styling diff --git a/core/scripts/js/vendor-update.js b/core/scripts/js/vendor-update.js index ef2b2c83463fbb02052ae73f59f6f85b22ea79ca..b7f2a210680cff6f98badd23c8f3f4fd6a3a202b 100644 --- a/core/scripts/js/vendor-update.js +++ b/core/scripts/js/vendor-update.js @@ -55,7 +55,7 @@ const assetsFolder = `${coreFolder}/assets/vendor`; * is not defined the value of `pack` is used. * @prop {string} [library] * The key under which the library is declared in core.libraries.yml. - * @prop {Array} files + * @prop {Array} [files] * An array of files to be copied over. * - A string if the file has the same name and is at the same level in * the source and target folder. @@ -76,8 +76,13 @@ const assetsFolder = `${coreFolder}/assets/vendor`; const ASSET_LIST = [ { pack: 'backbone', + library: 'internal.backbone', files: ['backbone.js', 'backbone-min.js', 'backbone-min.map'], }, + // Only used to update the version number of the deprecated library. + { + pack: 'backbone', + }, { pack: 'css.escape', folder: 'css-escape', diff --git a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php index a65139585e1c3d1beec9795cb744374dbd03d74c..d9dbdbdd2a7c2da24d451fa06475501653ea2e91 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php @@ -283,14 +283,14 @@ public function testBrowserConditionalComments() { * Tests JavaScript versioning. */ public function testVersionQueryString() { - $build['#attached']['library'][] = 'core/backbone'; + $build['#attached']['library'][] = 'core/once'; $assets = AttachedAssets::createFromRenderArray($build); $js = $this->assetResolver->getJsAssets($assets, FALSE)[1]; $js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js); $rendered_js = $this->renderer->renderPlain($js_render_array); - $this->assertStringContainsString('core/assets/vendor/backbone/backbone-min.js?v=1.4.0', $rendered_js, 'JavaScript version identifiers correctly appended to URLs'); + $this->assertStringContainsString('core/assets/vendor/once/once.min.js?v=1.0.1', $rendered_js, 'JavaScript version identifiers correctly appended to URLs'); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedBackboneTest.php b/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedBackboneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1cf562fb5ed90dc6d4295a0779c39bf6e714e76e --- /dev/null +++ b/core/tests/Drupal/KernelTests/Core/Asset/DeprecatedBackboneTest.php @@ -0,0 +1,38 @@ +<?php + +namespace Drupal\KernelTests\Core\Asset; + +use Drupal\KernelTests\KernelTestBase; + +/** + * Checks the deprecation status of Backbone. + * + * @group Asset + * @group legacy + */ +class DeprecatedBackboneTest extends KernelTestBase { + + /** + * The library discovery service. + * + * @var \Drupal\Core\Asset\LibraryDiscoveryInterface + */ + protected $libraryDiscovery; + + /** + * {@inheritdoc} + */ + protected function setUp():void { + parent::setUp(); + $this->libraryDiscovery = $this->container->get('library.discovery'); + } + + /** + * Tests that the Backbone library is deprecated. + */ + public function testBackboneDeprecation() { + $this->libraryDiscovery->getLibraryByName('core', 'backbone'); + $this->expectDeprecation("The core/backbone asset library is deprecated in Drupal 9.4.0 and will be removed in Drupal 10.0.0."); + } + +}