diff options
author | David Rothstein <drothstein@gmail.com> | 2014-11-03 00:39:48 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2014-11-03 00:39:48 -0500 |
commit | 62e874b348fe64490952a12f419164e26ea98d21 (patch) | |
tree | 1832d4d5e6c6077c54813a1dc31d400f8f80758a /misc | |
parent | 0c8dc6ea062cd7595a7b6fbd02fb0f0294ccecef (diff) | |
download | brdo-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 'misc')
-rw-r--r-- | misc/ajax.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/misc/ajax.js b/misc/ajax.js index 3b9dec614..01b894d75 100644 --- a/misc/ajax.js +++ b/misc/ajax.js @@ -619,6 +619,26 @@ Drupal.ajax.prototype.commands = { }, /** + * Command to add css. + * + * Uses the proprietary addImport method if available as browsers which + * support that method ignore @import statements in dynamically added + * stylesheets. + */ + add_css: function (ajax, response, status) { + // Add the styles in the normal way. + $('head').prepend(response.data); + // Add imports in the styles using the addImport method if available. + var match, importMatch = /^@import url\("(.*)"\);$/igm; + if (document.styleSheets[0].addImport && importMatch.test(response.data)) { + importMatch.lastIndex = 0; + while (match = importMatch.exec(response.data)) { + document.styleSheets[0].addImport(match[1]); + } + } + }, + + /** * Command to update a form's build ID. */ updateBuildId: function(ajax, response, status) { |