diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 05d307c01b3482cb89ae9af674d7506f8f5d1644..178702b2aff837e8607d720ec9f75245ed326b6b 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -211,28 +211,32 @@ function _drupal_theme_initialize($theme, $base_theme = array()) { drupal_render($css); // Do basically the same as the above for scripts - $final_libraries = array(); + $final_scripts = array(); // Grab scripts from base theme foreach ($base_theme as $base) { - if (!empty($base->libraries)) { - foreach ($base->libraries as $library) { - $final_libraries[] = $library; + if (!empty($base->scripts)) { + foreach ($base->scripts as $name => $script) { + $final_scripts[$name] = $script; } } } // Add scripts used by this theme. - if (!empty($theme->libraries)) { - foreach ($theme->libraries as $library) { - $final_libraries[] = $library; + if (!empty($theme->scripts)) { + foreach ($theme->scripts as $name => $script) { + $final_scripts[$name] = $script; } } // Add scripts used by this theme. $js = array(); - foreach ($final_libraries as $library) { - $js['#attached']['library'][] = $library; + foreach ($final_scripts as $script) { + $js['#attached']['js'][] = array( + 'data' => $script, + 'group' => JS_THEME, + 'every_page' => TRUE, + ); } drupal_render($js); diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index ba658c2ecde39d8f0b17272c892e12f68c9badbc..35ab1d48d75e7d4610c8c7c2defef2ccc7f02632 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -206,8 +206,8 @@ public function listInfo() { $theme->stylesheets[$media][$stylesheet] = $path; } } - foreach ($theme->info['libraries'] as $library => $name) { - $theme->libraries[$library] = $name; + foreach ($theme->info['scripts'] as $script => $path) { + $theme->scripts[$script] = $path; } if (isset($theme->info['engine'])) { $theme->engine = $theme->info['engine']; @@ -265,7 +265,7 @@ public function rebuildThemeData() { 'screenshot' => 'screenshot.png', 'php' => DRUPAL_MINIMUM_PHP, 'stylesheets' => array(), - 'libraries' => array(), + 'scripts' => array(), ); $sub_themes = array(); @@ -294,9 +294,10 @@ public function rebuildThemeData() { $theme->prefix = $engines[$engine]->getName(); } - // Prefix stylesheets and screenshot with theme path. + // Prefix stylesheets, scripts, and screenshot with theme path. $path = $theme->getPath(); $theme->info['stylesheets'] = $this->themeInfoPrefixPath($theme->info['stylesheets'], $path); + $theme->info['scripts'] = $this->themeInfoPrefixPath($theme->info['scripts'], $path); if (!empty($theme->info['screenshot'])) { $theme->info['screenshot'] = $path . '/' . $theme->info['screenshot']; } @@ -337,7 +338,7 @@ public function rebuildThemeData() { * * This helper function is mainly used to prefix all array values of an * .info.yml file property with a single given path (to the module or theme); - * e.g., to prefix all values of the 'stylesheets' properties + * e.g., to prefix all values of the 'stylesheets' or 'scripts' properties * with the file path to the defining module/theme. * * @param array $info diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 6ba25396bd2652c7d2a5866ef2c8bed2e1e4dc46..94df7412881ce21c4a95557ab737ea7e7b762bc2 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -196,8 +196,8 @@ public function testEnableAndListInfo() { 'css/colors.css', ), ), - 'libraries' => array( - 'example/theme', + 'scripts' => array( + 'example' => 'theme.js', ), 'engine' => 'twig', 'base theme' => 'stark', @@ -207,7 +207,7 @@ public function testEnableAndListInfo() { $this->assertCount(1, $list_info); $this->assertEquals($this->themeHandler->systemList['bartik']->info['stylesheets'], $list_info['bartik']->stylesheets); - $this->assertEquals($this->themeHandler->systemList['bartik']->libraries, $list_info['bartik']->libraries); + $this->assertEquals($this->themeHandler->systemList['bartik']->scripts, $list_info['bartik']->scripts); $this->assertEquals('twig', $list_info['bartik']->engine); $this->assertEquals('stark', $list_info['bartik']->base_theme); $this->assertEquals(0, $list_info['bartik']->status); @@ -219,7 +219,7 @@ public function testEnableAndListInfo() { 'style.css', ), ), - 'libraries' => array(), + 'scripts' => array(), ); $this->themeHandler->systemList['seven']->status = 1; @@ -274,7 +274,7 @@ public function testRebuildThemeData() { $this->assertEquals('twig', $info->prefix); $this->assertEquals('twig', $info->info['engine']); - $this->assertEquals(array(), $info->info['libraries']); + $this->assertEquals(array(), $info->info['scripts']); // Ensure that the css paths are set with the proper prefix. $this->assertEquals(array( diff --git a/core/themes/bartik/bartik.info.yml b/core/themes/bartik/bartik.info.yml index 6dda356da3d21fed01241eb78894cd01be516826..6851a12f11254af45153cb44964833dd7fbf0db3 100644 --- a/core/themes/bartik/bartik.info.yml +++ b/core/themes/bartik/bartik.info.yml @@ -4,11 +4,13 @@ description: 'A flexible, recolorable theme with many regions and a responsive, package: Core version: VERSION core: 8.x -libraries: - - bartik/base stylesheets: all: + - css/layout.css + - css/style.css - css/colors.css + print: + - css/print.css ckeditor_stylesheets: - css/ckeditor-iframe.css regions: diff --git a/core/themes/bartik/bartik.libraries.yml b/core/themes/bartik/bartik.libraries.yml index 04ec090fcbcb53ec0c325ba08455aa4684ec5bef..c86401677fca12f29b19e8c2d571458c103a3b01 100644 --- a/core/themes/bartik/bartik.libraries.yml +++ b/core/themes/bartik/bartik.libraries.yml @@ -1,11 +1,3 @@ -base: - version: VERSION - css: - theme: - css/layout.css: {} - css/style.css: {} - css/print.css: { media: print } - maintenance_page: version: VERSION css: