From 4ac6433a74df2e4b443fa6a314adb3ad4a152d8b Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 28 Feb 2012 22:11:46 -0800 Subject: Issue #967166 by effulgentsia, Cottser, no_commit_credit, KrisBulman: Fixed Content rendered via AJAX does not respect stylesheets removed in .info files. --- includes/common.inc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index d799616d4..021e1a47d 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -2969,6 +2969,18 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) { // Sort CSS items, so that they appear in the correct order. uasort($css, 'drupal_sort_css_js'); + // Provide the page with information about the individual CSS files used, + // information not otherwise available when CSS aggregation is enabled. The + // setting is attached later in this function, but is set here, so that CSS + // files removed below are still considered "used" and prevented from being + // added in a later AJAX request. + // Skip if no files were added to the page or jQuery.extend() will overwrite + // the Drupal.settings.ajaxPageState.css object with an empty array. + if (!empty($css)) { + // Cast the array to an object to be on the safe side even if not empty. + $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1); + } + // Remove the overridden CSS files. Later CSS files override former ones. $previous_item = array(); foreach ($css as $key => $item) { @@ -2989,13 +3001,7 @@ function drupal_get_css($css = NULL, $skip_alter = FALSE) { '#items' => $css, ); - // Provide the page with information about the individual CSS files used, - // information not otherwise available when CSS aggregation is enabled. - // Skip if no files were added to the page or jQuery.extend() will overwrite - // the Drupal.settings.ajaxPageState.css object with an empty array. - // Cast the array to an object to be on the safe side even if not empty. - if (!empty($css)) { - $setting['ajaxPageState']['css'] = (object) array_fill_keys(array_keys($css), 1); + if (!empty($setting)) { $styles['#attached']['js'][] = array('type' => 'setting', 'data' => $setting); } -- cgit v1.2.3