From 7c35e485fa59b9725bb1b14f6f930409db9762a5 Mon Sep 17 00:00:00 2001 From: Stanislas Rolland Date: Thu, 8 Sep 2011 10:24:03 -0400 Subject: [PATCH] [BUGFIX] RTE only loads styles from external css file on reload in IE8 Problem: The script fails to detect that a stylesheet is not loaded Solution: Check for empty rules and imports arrays of skin and content stylesheets. Change-Id: Ie9669ca79e7814805dc5dbcd29f5f65939524071 Resolves: #29234 Releases: 4.5, 4.6 Reviewed-on: http://review.typo3.org/4858 Reviewed-by: Stanislas Rolland Tested-by: Stanislas Rolland --- typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js b/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js index 9dc89e31a9ac..2c733dc5fee4 100644 --- a/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js +++ b/typo3/sysext/rtehtmlarea/htmlarea/htmlarea.js @@ -3522,7 +3522,7 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, { try { var rules = this.editor.document.styleSheets[0].rules; var imports = this.editor.document.styleSheets[0].imports; - if ((!rules || !rules.length) && (!imports || !imports.length)) { + if (!rules.length && !imports.length) { this.cssLoaded = false; this.error = 'Empty rules and imports arrays'; } @@ -3540,10 +3540,19 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, { } } if (this.cssLoaded) { - if (this.editor.document.styleSheets.length) { - Ext.each(this.editor.document.styleSheets, function (styleSheet) { + // Expecting 3 stylesheets... + if (this.editor.document.styleSheets.length > 2) { + Ext.each(this.editor.document.styleSheets, function (styleSheet, index) { try { if (Ext.isIE) { + var rules = styleSheet.rules; + var imports = styleSheet.imports; + // Default page style may contain only a comment + if (!rules.length && !imports.length && index != 1) { + this.cssLoaded = false; + this.error = 'Empty rules and imports arrays of styleSheets[' + index + ']'; + return false; + } if (styleSheet.imports) { this.parseIeRules(styleSheet.imports); } @@ -3562,7 +3571,7 @@ HTMLArea.CSS.Parser = Ext.extend(Ext.util.Observable, { }, this); } else { this.cssLoaded = false; - this.error = 'Empty stylesheets array'; + this.error = 'Empty stylesheets array or missing linked stylesheets'; } } }, -- 2.20.1