[BUGFIX] RTE only loads styles from external css file on reload in IE8
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 8 Sep 2011 14:24:03 +0000 (10:24 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 8 Sep 2011 14:39:45 +0000 (16:39 +0200)
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

index 9dc89e3..2c733dc 100644 (file)
@@ -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';
                        }
                }
        },