diff --git a/includes/common.inc b/includes/common.inc index 20cc82b..319a9af 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3029,6 +3029,16 @@ function drupal_add_css($data = NULL, $options = NULL) { // Always add a tiny value to the weight, to conserve the insertion order. $options['weight'] += count($css) / 1000; + // In case we already have this, re-use the earlier weight. + // Else the same files will end up with the same weight + // as the count does not change when a file is replaced. + // Besides that the latest insertion would count, + // but we want the earliest one. + if ($options['type'] != 'inline' && isset($css[$data])) { + // Re-use the earlier weight. + $options['weight'] = $css[$data]['weight']; + } + // Add the data to the CSS array depending on the type. switch ($options['type']) { case 'inline': @@ -4176,6 +4186,17 @@ function drupal_add_js($data = NULL, $options = NULL) { // order of the calls to drupal_add_js(). $options['weight'] += count($javascript) / 1000; + // In case we already have this, re-use the earlier weight. + // Else the same files will end up with the same weight + // as the count does not change when a file is replaced. + // Besides that the latest insertion would count, + // but we want the earliest one. + if ($options['type'] != 'setting' + && $options['type'] != 'inline' + && isset($javascript[$options['data']])) { + $options['weight'] = $javascript[$options['data']]['weight']; + } + if (isset($data)) { // Add jquery.js and drupal.js, as well as the basePath setting, the // first time a JavaScript file is added.