summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-03 00:39:48 -0500
committerDavid Rothstein <drothstein@gmail.com>2014-11-03 00:39:48 -0500
commit62e874b348fe64490952a12f419164e26ea98d21 (patch)
tree1832d4d5e6c6077c54813a1dc31d400f8f80758a /includes
parent0c8dc6ea062cd7595a7b6fbd02fb0f0294ccecef (diff)
downloadbrdo-62e874b348fe64490952a12f419164e26ea98d21.tar.gz
brdo-62e874b348fe64490952a12f419164e26ea98d21.tar.bz2
Issue #1071818 by JeremyFrench, nod_, Cottser, gielfeldt, xjm, anthbel, reglogge, NROTC_Webmaster, kristofferwiklund, lliss, sun | sepgil: Fixed Lazy-loading CSS fails in IE.
Diffstat (limited to 'includes')
-rw-r--r--includes/ajax.inc25
-rw-r--r--includes/common.inc6
2 files changed, 29 insertions, 2 deletions
diff --git a/includes/ajax.inc b/includes/ajax.inc
index 31067c3e0..10877a246 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -276,7 +276,7 @@ function ajax_render($commands = array()) {
$extra_commands = array();
if (!empty($styles)) {
- $extra_commands[] = ajax_command_prepend('head', $styles);
+ $extra_commands[] = ajax_command_add_css($styles);
}
if (!empty($scripts_header)) {
$extra_commands[] = ajax_command_prepend('head', $scripts_header);
@@ -1257,3 +1257,26 @@ function ajax_command_update_build_id($form) {
'new' => $form['#build_id'],
);
}
+
+/**
+ * Creates a Drupal Ajax 'add_css' command.
+ *
+ * This method will add css via ajax in a cross-browser compatible way.
+ *
+ * This command is implemented by Drupal.ajax.prototype.commands.add_css()
+ * defined in misc/ajax.js.
+ *
+ * @param $styles
+ * A string that contains the styles to be added.
+ *
+ * @return
+ * An array suitable for use with the ajax_render() function.
+ *
+ * @see misc/ajax.js
+ */
+function ajax_command_add_css($styles) {
+ return array(
+ 'command' => 'add_css',
+ 'data' => $styles,
+ );
+}
diff --git a/includes/common.inc b/includes/common.inc
index e7e293917..1bfff345b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3474,7 +3474,11 @@ function drupal_pre_render_styles($elements) {
$import_batch = array_slice($import, 0, 31);
$import = array_slice($import, 31);
$element = $style_element_defaults;
- $element['#value'] = implode("\n", $import_batch);
+ // This simplifies the JavaScript regex, allowing each line
+ // (separated by \n) to be treated as a completely different string.
+ // This means that we can use ^ and $ on one line at a time, and not
+ // worry about style tags since they'll never match the regex.
+ $element['#value'] = "\n" . implode("\n", $import_batch) . "\n";
$element['#attributes']['media'] = $group['media'];
$element['#browsers'] = $group['browsers'];
$elements[] = $element;