Commit 7a6602c8 authored by catch's avatar catch

Issue #977844 by Wim Leers: Remove the 'every_page' option for CSS/JS assets:...

Issue #977844 by Wim Leers: Remove the 'every_page' option for CSS/JS assets: it is confusing, even damaging
parent 22fbcd41
......@@ -332,7 +332,7 @@ html5shiv:
url: http://www.gnu.org/licenses/gpl-2.0.html
gpl-compatible: true
js:
assets/vendor/html5shiv/html5shiv.min.js: { every_page: true, weight: -22, browsers: { IE: 'lte IE 8', '!IE': false }, minified: true }
assets/vendor/html5shiv/html5shiv.min.js: { weight: -22, browsers: { IE: 'lte IE 8', '!IE': false }, minified: true }
jquery:
remote: https://github.com/jquery/jquery
......@@ -826,7 +826,7 @@ modernizr:
gpl-compatible: true
version: "v2.8.3"
js:
assets/vendor/modernizr/modernizr.min.js: { every_page: true, preprocess: 0, weight: -21, minified: true }
assets/vendor/modernizr/modernizr.min.js: { preprocess: 0, weight: -21, minified: true }
normalize:
remote: https://github.com/necolas/normalize.css
......@@ -837,7 +837,7 @@ normalize:
gpl-compatible: true
css:
base:
assets/vendor/normalize-css/normalize.css: { every_page: true, weight: -20 }
assets/vendor/normalize-css/normalize.css: { weight: -20 }
picturefill:
remote: https://github.com/scottjehl/picturefill
......
......@@ -521,7 +521,6 @@ function drupal_js_defaults($data = NULL) {
return array(
'type' => 'file',
'group' => JS_DEFAULT,
'every_page' => FALSE,
'weight' => 0,
'scope' => 'header',
'cache' => TRUE,
......
......@@ -127,7 +127,6 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) {
'type' => 'file',
'group' => CSS_AGGREGATE_DEFAULT,
'weight' => 0,
'every_page' => FALSE,
'media' => 'all',
'preprocess' => TRUE,
'browsers' => [],
......@@ -231,7 +230,6 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
$default_options = [
'type' => 'file',
'group' => JS_DEFAULT,
'every_page' => FALSE,
'weight' => 0,
'cache' => TRUE,
'preprocess' => TRUE,
......@@ -338,7 +336,6 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) {
$settings_as_inline_javascript = [
'type' => 'setting',
'group' => JS_SETTING,
'every_page' => TRUE,
'weight' => 0,
'browsers' => [],
'data' => $settings,
......@@ -384,16 +381,6 @@ public static function sort($a, $b) {
elseif ($a['group'] > $b['group']) {
return 1;
}
// Within a group, order all infrequently needed, page-specific files after
// common files needed throughout the website. Separating this way allows
// for the aggregate file generated for all of the common files to be reused
// across a site visit without being cut by a page using a less common file.
elseif ($a['every_page'] && !$b['every_page']) {
return -1;
}
elseif (!$a['every_page'] && $b['every_page']) {
return 1;
}
// Finally, order by weight.
elseif ($a['weight'] < $b['weight']) {
return -1;
......
......@@ -58,9 +58,8 @@ public function group(array $css_assets) {
case 'file':
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value and 'every_page'
// flag.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['media'], $item['browsers']) : FALSE;
// together items that share the same 'group' value.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE;
break;
case 'inline':
......
......@@ -103,7 +103,7 @@ public function render(array $css_assets) {
// For filthy IE hack.
$current_ie_group_keys = NULL;
$get_ie_group_key = function ($css_asset) {
return array($css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['every_page'], $css_asset['media'], $css_asset['browsers']);
return array($css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['media'], $css_asset['browsers']);
};
// Loop through all CSS assets, by key, to allow for the special IE
......@@ -123,9 +123,9 @@ public function render(array $css_assets) {
// LINK tag.
// - file CSS assets that can be aggregated (and possibly have been):
// in this case, figure out which subsequent file CSS assets share
// the same key properties ('group', 'every_page', 'media' and
// 'browsers') and output this group into as few STYLE tags as
// possible (a STYLE tag may contain only 31 @import statements).
// the same key properties ('group', 'media' and 'browsers') and
// output this group into as few STYLE tags as possible (a STYLE
// tag may contain only 31 @import statements).
case 'file':
// The dummy query string needs to be added to the URL to control
// browser-caching.
......@@ -159,7 +159,7 @@ public function render(array $css_assets) {
$import = array();
// Start with the current CSS asset, iterate over subsequent CSS
// assets and find which ones have the same 'type', 'group',
// 'every_page', 'preprocess', 'media' and 'browsers' properties.
// 'preprocess', 'media' and 'browsers' properties.
$j = $i;
$next_css_asset = $css_asset;
$current_ie_group_key = $get_ie_group_key($css_asset);
......
......@@ -45,9 +45,8 @@ public function group(array $js_assets) {
case 'file':
// Group file items if their 'preprocess' flag is TRUE.
// Help ensure maximum reuse of aggregate files by only grouping
// together items that share the same 'group' value and 'every_page'
// flag.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['every_page'], $item['browsers']) : FALSE;
// together items that share the same 'group' value.
$group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['browsers']) : FALSE;
break;
case 'external':
......
......@@ -3,49 +3,49 @@ base:
css:
# Adjust the weights to load these early.
component:
css/components/ajax-progress.module.css: { every_page: true, weight: -10 }
css/components/align.module.css: { every_page: true, weight: -10 }
css/components/autocomplete-loading.module.css: { every_page: true, weight: -10 }
css/components/fieldgroup.module.css: { every_page: true, weight: -10 }
css/components/container-inline.module.css: { every_page: true, weight: -10 }
css/components/clearfix.module.css: { every_page: true, weight: -10 }
css/components/details.module.css: { every_page: true, weight: -10 }
css/components/hidden.module.css: { every_page: true, weight: -10 }
css/components/js.module.css: { every_page: true, weight: -10 }
css/components/nowrap.module.css: { every_page: true, weight: -10 }
css/components/position-container.module.css: { every_page: true, weight: -10 }
css/components/progress.module.css: { every_page: true, weight: -10 }
css/components/reset-appearance.module.css: { every_page: true, weight: -10 }
css/components/resize.module.css: { every_page: true, weight: -10 }
css/components/sticky-header.module.css: { every_page: true, weight: -10 }
css/components/tabledrag.module.css: { every_page: true, weight: -10 }
css/components/ajax-progress.module.css: { weight: -10 }
css/components/align.module.css: { weight: -10 }
css/components/autocomplete-loading.module.css: { weight: -10 }
css/components/fieldgroup.module.css: { weight: -10 }
css/components/container-inline.module.css: { weight: -10 }
css/components/clearfix.module.css: { weight: -10 }
css/components/details.module.css: { weight: -10 }
css/components/hidden.module.css: { weight: -10 }
css/components/js.module.css: { weight: -10 }
css/components/nowrap.module.css: { weight: -10 }
css/components/position-container.module.css: { weight: -10 }
css/components/progress.module.css: { weight: -10 }
css/components/reset-appearance.module.css: { weight: -10 }
css/components/resize.module.css: { weight: -10 }
css/components/sticky-header.module.css: { weight: -10 }
css/components/tabledrag.module.css: { weight: -10 }
theme:
css/components/action-links.theme.css: { every_page: true, weight: -10 }
css/components/breadcrumb.theme.css: { every_page: true, weight: -10 }
css/components/button.theme.css: { every_page: true, weight: -10 }
css/components/collapse-processed.theme.css: { every_page: true, weight: -10 }
css/components/container-inline.theme.css: { every_page: true, weight: -10 }
css/components/details.theme.css: { every_page: true, weight: -10 }
css/components/exposed-filters.theme.css: { every_page: true, weight: -10 }
css/components/field.theme.css: { every_page: true, weight: -10 }
css/components/form.theme.css: { every_page: true, weight: -10 }
css/components/icons.theme.css: { every_page: true, weight: -10 }
css/components/inline-form.theme.css: { every_page: true, weight: -10 }
css/components/item-list.theme.css: { every_page: true, weight: -10 }
css/components/link.theme.css: { every_page: true, weight: -10 }
css/components/links.theme.css: { every_page: true, weight: -10 }
css/components/menu.theme.css: { every_page: true, weight: -10 }
css/components/messages.theme.css: { every_page: true, weight: -10 }
css/components/more-link.theme.css: { every_page: true, weight: -10 }
css/components/node.theme.css: { every_page: true, weight: -10 }
css/components/pager.theme.css: { every_page: true, weight: -10 }
css/components/progress.theme.css: { every_page: true, weight: -10 }
css/components/tableselect.theme.css: { every_page: true, weight: -10 }
css/components/tabledrag.theme.css: { every_page: true, weight: -10 }
css/components/tablesort.theme.css: { every_page: true, weight: -10 }
css/components/tabs.theme.css: { every_page: true, weight: -10 }
css/components/textarea.theme.css: { every_page: true, weight: -10 }
css/components/tree-child.module.css: { every_page: true, weight: -10 }
css/components/action-links.theme.css: { weight: -10 }
css/components/breadcrumb.theme.css: { weight: -10 }
css/components/button.theme.css: { weight: -10 }
css/components/collapse-processed.theme.css: { weight: -10 }
css/components/container-inline.theme.css: { weight: -10 }
css/components/details.theme.css: { weight: -10 }
css/components/exposed-filters.theme.css: { weight: -10 }
css/components/field.theme.css: { weight: -10 }
css/components/form.theme.css: { weight: -10 }
css/components/icons.theme.css: { weight: -10 }
css/components/inline-form.theme.css: { weight: -10 }
css/components/item-list.theme.css: { weight: -10 }
css/components/link.theme.css: { weight: -10 }
css/components/links.theme.css: { weight: -10 }
css/components/menu.theme.css: { weight: -10 }
css/components/messages.theme.css: { weight: -10 }
css/components/more-link.theme.css: { weight: -10 }
css/components/node.theme.css: { weight: -10 }
css/components/pager.theme.css: { weight: -10 }
css/components/progress.theme.css: { weight: -10 }
css/components/tableselect.theme.css: { weight: -10 }
css/components/tabledrag.theme.css: { weight: -10 }
css/components/tablesort.theme.css: { weight: -10 }
css/components/tabs.theme.css: { weight: -10 }
css/components/textarea.theme.css: { weight: -10 }
css/components/tree-child.module.css: { weight: -10 }
admin:
version: VERSION
......
......@@ -38,7 +38,6 @@ function testGrouper() {
$css_assets = array(
'system.base.css' => array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
......@@ -49,7 +48,6 @@ function testGrouper() {
),
'system.theme.css' => array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -62,7 +60,6 @@ function testGrouper() {
'group' => -100,
'type' => 'file',
'weight' => 0.004,
'every_page' => FALSE,
'media' => 'all',
'preprocess' => TRUE,
'data' => 'core/misc/ui/themes/base/jquery.ui.core.css',
......@@ -70,7 +67,6 @@ function testGrouper() {
'basename' => 'jquery.ui.core.css',
),
'field.css' => array(
'every_page' => TRUE,
'group' => 0,
'type' => 'file',
'weight' => 0.011,
......@@ -81,7 +77,6 @@ function testGrouper() {
'basename' => 'field.css',
),
'external.css' => array(
'every_page' => FALSE,
'group' => 0,
'type' => 'external',
'weight' => 0.009,
......@@ -93,7 +88,6 @@ function testGrouper() {
),
'elements.css' => array(
'group' => 100,
'every_page' => TRUE,
'media' => 'all',
'type' => 'file',
'weight' => 0.001,
......@@ -104,7 +98,6 @@ function testGrouper() {
),
'print.css' => array(
'group' => 100,
'every_page' => TRUE,
'media' => 'print',
'type' => 'file',
'weight' => 0.003,
......@@ -117,62 +110,53 @@ function testGrouper() {
$groups = $this->grouper->group($css_assets);
$this->assertSame(count($groups), 6, "6 groups created.");
$this->assertSame(count($groups), 5, "5 groups created.");
// Check group 1.
$this->assertSame($groups[0]['group'], -100);
$this->assertSame($groups[0]['every_page'], TRUE);
$this->assertSame($groups[0]['type'], 'file');
$this->assertSame($groups[0]['media'], 'all');
$this->assertSame($groups[0]['preprocess'], TRUE);
$this->assertSame(count($groups[0]['items']), 2);
$this->assertContains($css_assets['system.base.css'], $groups[0]['items']);
$this->assertContains($css_assets['system.theme.css'], $groups[0]['items']);
$group = $groups[0];
$this->assertSame($group['group'], -100);
$this->assertSame($group['type'], 'file');
$this->assertSame($group['media'], 'all');
$this->assertSame($group['preprocess'], TRUE);
$this->assertSame(count($group['items']), 3);
$this->assertContains($css_assets['system.base.css'], $group['items']);
$this->assertContains($css_assets['system.theme.css'], $group['items']);
// Check group 2.
$this->assertSame($groups[1]['group'], -100);
$this->assertSame($groups[1]['every_page'], FALSE);
$this->assertSame($groups[1]['type'], 'file');
$this->assertSame($groups[1]['media'], 'all');
$this->assertSame($groups[1]['preprocess'], TRUE);
$this->assertSame(count($groups[1]['items']), 1);
$this->assertContains($css_assets['jquery.ui.core.css'], $groups[1]['items']);
$group = $groups[1];
$this->assertSame($group['group'], 0);
$this->assertSame($group['type'], 'file');
$this->assertSame($group['media'], 'all');
$this->assertSame($group['preprocess'], TRUE);
$this->assertSame(count($group['items']), 1);
$this->assertContains($css_assets['field.css'], $group['items']);
// Check group 3.
$this->assertSame($groups[2]['group'], 0);
$this->assertSame($groups[2]['every_page'], TRUE);
$this->assertSame($groups[2]['type'], 'file');
$this->assertSame($groups[2]['media'], 'all');
$this->assertSame($groups[2]['preprocess'], TRUE);
$this->assertSame(count($groups[2]['items']), 1);
$this->assertContains($css_assets['field.css'], $groups[2]['items']);
$group = $groups[2];
$this->assertSame($group['group'], 0);
$this->assertSame($group['type'], 'external');
$this->assertSame($group['media'], 'all');
$this->assertSame($group['preprocess'], TRUE);
$this->assertSame(count($group['items']), 1);
$this->assertContains($css_assets['external.css'], $group['items']);
// Check group 4.
$this->assertSame($groups[3]['group'], 0);
$this->assertSame($groups[3]['every_page'], FALSE);
$this->assertSame($groups[3]['type'], 'external');
$this->assertSame($groups[3]['media'], 'all');
$this->assertSame($groups[3]['preprocess'], TRUE);
$this->assertSame(count($groups[3]['items']), 1);
$this->assertContains($css_assets['external.css'], $groups[3]['items']);
$group = $groups[3];
$this->assertSame($group['group'], 100);
$this->assertSame($group['type'], 'file');
$this->assertSame($group['media'], 'all');
$this->assertSame($group['preprocess'], TRUE);
$this->assertSame(count($group['items']), 1);
$this->assertContains($css_assets['elements.css'], $group['items']);
// Check group 5.
$this->assertSame($groups[4]['group'], 100);
$this->assertSame($groups[4]['every_page'], TRUE);
$this->assertSame($groups[4]['type'], 'file');
$this->assertSame($groups[4]['media'], 'all');
$this->assertSame($groups[4]['preprocess'], TRUE);
$this->assertSame(count($groups[4]['items']), 1);
$this->assertContains($css_assets['elements.css'], $groups[4]['items']);
// Check group 6.
$this->assertSame($groups[5]['group'], 100);
$this->assertSame($groups[5]['every_page'], TRUE);
$this->assertSame($groups[5]['type'], 'file');
$this->assertSame($groups[5]['media'], 'print');
$this->assertSame($groups[5]['preprocess'], TRUE);
$this->assertSame(count($groups[5]['items']), 1);
$this->assertContains($css_assets['print.css'], $groups[5]['items']);
$group = $groups[4];
$this->assertSame($group['group'], 100);
$this->assertSame($group['type'], 'file');
$this->assertSame($group['media'], 'print');
$this->assertSame($group['preprocess'], TRUE);
$this->assertSame(count($group['items']), 1);
$this->assertContains($css_assets['print.css'], $group['items']);
}
}
......@@ -71,7 +71,6 @@ protected function setUp() {
$this->renderer = new CssCollectionRenderer($this->state);
$this->fileCssGroup = array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'media' => 'all',
'preprocess' => TRUE,
......@@ -79,7 +78,6 @@ protected function setUp() {
'items' => array(
0 => array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
......@@ -90,7 +88,6 @@ protected function setUp() {
),
1 => array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -135,7 +132,7 @@ function providerTestRender() {
};
$create_file_css_asset = function($data, $media = 'all', $preprocess = TRUE) {
return array('group' => 0, 'every_page' => FALSE, 'type' => 'file', 'media' => $media, 'preprocess' => $preprocess, 'data' => $data, 'browsers' => array());
return array('group' => 0, 'type' => 'file', 'media' => $media, 'preprocess' => $preprocess, 'data' => $data, 'browsers' => array());
};
return array(
......@@ -143,7 +140,7 @@ function providerTestRender() {
0 => array(
// CSS assets.
array(
0 => array('group' => 0, 'every_page' => TRUE, 'type' => 'external', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'http://example.com/popular.js', 'browsers' => array()),
0 => array('group' => 0, 'type' => 'external', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'http://example.com/popular.js', 'browsers' => array()),
),
// Render elements.
array(
......@@ -153,10 +150,10 @@ function providerTestRender() {
// Single file CSS asset.
2 => array(
array(
0 => array('group' => 0, 'every_page' => TRUE, 'type' => 'file', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'public://css/file-every_page-all', 'browsers' => array()),
0 => array('group' => 0, 'type' => 'file', 'media' => 'all', 'preprocess' => TRUE, 'data' => 'public://css/file-all', 'browsers' => array()),
),
array(
0 => $create_link_element(file_create_url('public://css/file-every_page-all') . '?0', 'all'),
0 => $create_link_element(file_create_url('public://css/file-all') . '?0', 'all'),
),
),
// 31 file CSS assets: expect 31 link elements.
......@@ -490,7 +487,6 @@ function testRenderInvalidType() {
$css_group = array(
'group' => 0,
'every_page' => TRUE,
'type' => 'internal',
'media' => 'all',
'preprocess' => TRUE,
......
......@@ -74,7 +74,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
......@@ -95,7 +94,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -111,7 +109,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -129,7 +126,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -146,7 +142,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -160,7 +155,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -174,7 +168,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -188,7 +181,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -202,7 +194,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -216,7 +207,6 @@ function providerTestOptimize() {
array(
array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.013,
'media' => 'all',
......@@ -247,7 +237,6 @@ function testTypeFilePreprocessingDisabled() {
$css_asset = array(
'group' => -100,
'every_page' => TRUE,
'type' => 'file',
'weight' => 0.012,
'media' => 'all',
......@@ -268,7 +257,6 @@ function testTypeExternal() {
$css_asset = array(
'group' => -100,
'every_page' => TRUE,
// Type external.
'type' => 'external',
'weight' => 0.012,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment