diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php index bc8f69f..7d959d4 100644 --- a/core/lib/Drupal/Core/Asset/AssetResolver.php +++ b/core/lib/Drupal/Core/Asset/AssetResolver.php @@ -137,15 +137,6 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { // Sort CSS items, so that they appear in the correct order. uasort($css, 'static::sort'); - // Allow themes to remove CSS files by CSS files full path and file name. - if ($stylesheet_remove = $theme_info->getStyleSheetsRemove()) { - foreach ($css as $key => $options) { - if (isset($stylesheet_remove[$key])) { - unset($css[$key]); - } - } - } - if ($optimize) { $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css); } diff --git a/core/lib/Drupal/Core/Theme/ActiveTheme.php b/core/lib/Drupal/Core/Theme/ActiveTheme.php index d1970e7..a282434 100644 --- a/core/lib/Drupal/Core/Theme/ActiveTheme.php +++ b/core/lib/Drupal/Core/Theme/ActiveTheme.php @@ -60,13 +60,6 @@ class ActiveTheme { protected $extension; /** - * The stylesheets which are set to be removed by the theme. - * - * @var array - */ - protected $styleSheetsRemove; - - /** * The libraries provided by the theme. * * @var array @@ -91,7 +84,6 @@ public function __construct(array $values) { 'path' => '', 'engine' => 'twig', 'owner' => 'twig', - 'stylesheets_remove' => [], 'libraries' => [], 'extension' => 'html.twig', 'base_themes' => [], @@ -102,7 +94,6 @@ public function __construct(array $values) { $this->path = $values['path']; $this->engine = $values['engine']; $this->owner = $values['owner']; - $this->styleSheetsRemove = $values['stylesheets_remove']; $this->libraries = $values['libraries']; $this->extension = $values['extension']; $this->baseThemes = $values['base_themes']; @@ -166,15 +157,6 @@ public function getLibraries() { } /** - * Returns the removed stylesheets by the theme. - * - * @return mixed - */ - public function getStyleSheetsRemove() { - return $this->styleSheetsRemove; - } - - /** * Returns an array of base theme active theme objects keyed by name. * * The order starts with the base theme of $this and ends with the root of diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index 6697d9b..7231610 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -161,31 +161,9 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) { $values['path'] = $theme_path; $values['name'] = $theme->getName(); - // Prepare stylesheets from this theme as well as all ancestor themes. - // We work it this way so that we can have child themes remove CSS files - // easily from parent. - $values['stylesheets_remove'] = array(); - - // Grab stylesheets from base theme. - foreach ($base_themes as $base) { - $base_theme_path = $base->getPath(); - if (!empty($base->info['stylesheets-remove'])) { - foreach ($base->info['stylesheets-remove'] as $css_file) { - $css_file = $this->resolveStyleSheetPlaceholders($css_file); - $values['stylesheets_remove'][$css_file] = $css_file; - } - } - } - - // Add stylesheets used by this theme. - if (!empty($theme->info['stylesheets-remove'])) { - foreach ($theme->info['stylesheets-remove'] as $css_file) { - $css_file = $this->resolveStyleSheetPlaceholders($css_file); - $values['stylesheets_remove'][$css_file] = $css_file; - } - } - // Prepare libraries overrides from this theme and ancestor themes. + // This allows child themes to easily remove CSS files from base themes and + // modules. $values['libraries_override'] = array(); // Grab libraries-overrides from base theme. diff --git a/core/modules/system/src/Tests/Theme/ThemeInfoTest.php b/core/modules/system/src/Tests/Theme/ThemeInfoTest.php index 3d376ed..bc3acc9 100644 --- a/core/modules/system/src/Tests/Theme/ThemeInfoTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeInfoTest.php @@ -56,7 +56,7 @@ protected function setUp() { } /** - * Tests stylesheets-remove. + * Tests stylesheets removed by libraries-override. */ function testStylesheets() { $this->themeHandler->install(array('test_basetheme', 'test_subtheme')); diff --git a/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml b/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml index dcb1a2f..d545822 100644 --- a/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml +++ b/core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml @@ -5,5 +5,5 @@ version: VERSION core: 8.x libraries: - test_basetheme/global-styling -stylesheets-remove: - - '@theme_test/css/base-remove.css' +libraries-override: + theme_test/theme_stylesheets_override_and_remove_test/css/base/css/base-remove.css: false diff --git a/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml b/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml index 6883e5a..bd6a625 100644 --- a/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml +++ b/core/modules/system/tests/themes/test_subtheme/test_subtheme.info.yml @@ -6,6 +6,6 @@ core: 8.x base theme: test_basetheme libraries: - test_subtheme/global-styling -stylesheets-remove: - - '@theme_test/css/sub-remove.css' - - '@test_basetheme/base-add.sub-remove.css' +libraries-override: + theme_test/theme_stylesheets_override_and_remove_test/css/base/css/sub-remove.css: false + test_basetheme/global-styling/css/base/base-add.sub-remove.css: false diff --git a/core/modules/system/tests/themes/test_theme/test_theme.info.yml b/core/modules/system/tests/themes/test_theme/test_theme.info.yml index d81c4e3..9e63615 100644 --- a/core/modules/system/tests/themes/test_theme/test_theme.info.yml +++ b/core/modules/system/tests/themes/test_theme/test_theme.info.yml @@ -14,19 +14,18 @@ description: 'Theme for testing the theme system' version: VERSION base theme: classy core: 8.x -stylesheets-remove: - - '@system/css/system.module.css' -regions: - content: Content - left: Left - right: Right - libraries-override: + system/base/css/component/css/system.module.css: false # Replace an entire library. - core/drupal.collapse: 'test_theme/collapse' + core/drupal.collapse: test_theme/collapse # Remove an entire library. - core/drupal.progress: FALSE + core/drupal.progress: false # Replace one particular library asset with another. - classy/base/css/theme/css/layout.css: 'css/test_theme_layout.css' + classy/base/css/theme/css/layout.css: css/test_theme_layout.css # Remove one particular asset. - core/drupal.dialog/css/theme/misc/dialog.theme.css: FALSE + core/drupal.dialog/css/theme/misc/dialog.theme.css: false +regions: + content: Content + left: Left + right: Right + diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index 4a9101d..3fe4054 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -92,8 +92,7 @@ public function testGetRegistryForModule() { 'path' => 'core/modules/system/tests/themes/test_theme/test_theme.info.yml', 'engine' => 'twig', 'owner' => 'twig', - 'stylesheets_remove' => [], - 'stylesheets_override' => [], + 'libraries_override' => [], 'libraries' => [], 'extension' => '.twig', 'base_themes' => [], diff --git a/core/themes/seven/seven.info.yml b/core/themes/seven/seven.info.yml index 99a3ec1..daf74a0 100644 --- a/core/themes/seven/seven.info.yml +++ b/core/themes/seven/seven.info.yml @@ -8,9 +8,9 @@ version: VERSION core: 8.x libraries: - seven/global-styling -stylesheets-remove: - - core/assets/vendor/jquery.ui/themes/base/dialog.css - - '@classy/css/layout.css' +libraries-override: + core/jquery.ui.dialog/css/component/assets/vendor/jquery.ui/themes/base/dialog.css: false + classy/base/css/theme/css/layout.css: false quickedit_stylesheets: - css/components/quickedit.css regions: diff --git a/core/themes/stark/stark.info.yml b/core/themes/stark/stark.info.yml index bd520f5..48df350 100644 --- a/core/themes/stark/stark.info.yml +++ b/core/themes/stark/stark.info.yml @@ -6,5 +6,5 @@ version: VERSION core: 8.x libraries: - stark/global-styling -stylesheets-remove: - - core/assets/vendor/normalize-css/normalize.css +libraries-override: + core/normalize/css/base/assets/vendor/normalize-css/normalize.css: false