[Pkg-javascript-commits] [less.js] 30/50: Set CSS text after style element is added to DOM, to fix crash on IE < 9.
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:22:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v1.7.1
in repository less.js.
commit c75bb15b2a0779098a00554890676d7acb774a0d
Author: David-Hari <d-hari at hotmail.com>
Date: Fri May 9 16:22:17 2014 +1000
Set CSS text after style element is added to DOM, to fix crash on IE < 9.
---
lib/less/browser.js | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/lib/less/browser.js b/lib/less/browser.js
index 613a22e..fbcf40b 100644
--- a/lib/less/browser.js
+++ b/lib/less/browser.js
@@ -118,13 +118,7 @@ function createCSS(styles, sheet, lastModified) {
}
css.id = id;
- if (css.styleSheet) { // IE
- try {
- css.styleSheet.cssText = styles;
- } catch (e) {
- throw new(Error)("Couldn't reassign styleSheet.cssText.");
- }
- } else {
+ if (!css.styleSheet) {
css.appendChild(document.createTextNode(styles));
// If new contents match contents of oldCss, don't replace oldCss
@@ -148,6 +142,17 @@ function createCSS(styles, sheet, lastModified) {
oldCss.parentNode.removeChild(oldCss);
}
+ // For IE.
+ // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.
+ // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head
+ if (css.styleSheet) {
+ try {
+ css.styleSheet.cssText = styles;
+ } catch (e) {
+ throw new(Error)("Couldn't reassign styleSheet.cssText.");
+ }
+ }
+
// Don't update the local store if the file wasn't modified
if (lastModified && cache) {
log('saving ' + href + ' to cache.', logLevel.info);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list