From 62e874b348fe64490952a12f419164e26ea98d21 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Mon, 3 Nov 2014 00:39:48 -0500 Subject: Issue #1071818 by JeremyFrench, nod_, Cottser, gielfeldt, xjm, anthbel, reglogge, NROTC_Webmaster, kristofferwiklund, lliss, sun | sepgil: Fixed Lazy-loading CSS fails in IE. --- misc/ajax.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'misc/ajax.js') diff --git a/misc/ajax.js b/misc/ajax.js index 3b9dec614..01b894d75 100644 --- a/misc/ajax.js +++ b/misc/ajax.js @@ -618,6 +618,26 @@ Drupal.ajax.prototype.commands = { .filter(':odd').addClass('even'); }, + /** + * 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. */ -- cgit v1.2.3