[FIX]web_editor: Fixed the issue of firefox not able to enumerate on cssRules, it is due to Cross domain security policy of firefox, used try catch, so that if there is cross domain css then skip it, it should not break the system, atleast it should work for same domain css, cross domain css should skipped
This commit is contained in:
committed by
Christophe Matthieu
parent
5a4c8998e7
commit
d434500ec8
@@ -12,7 +12,19 @@ var getMatchedCSSRules = function (a) {
|
||||
if (!rulesCache.length) {
|
||||
var sheets = document.styleSheets;
|
||||
for(var i = sheets.length-1; i >= 0 ; i--) {
|
||||
var rules = sheets[i].rules || sheets[i].cssRules;
|
||||
var rules;
|
||||
if (sheets[i].rules) {
|
||||
rules = sheets[i].rules;
|
||||
} else {
|
||||
//try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
|
||||
try {
|
||||
rules = sheets[i].cssRules;
|
||||
} catch(e) {
|
||||
console.warn("Can't read the css rules of: " + sheets[i].href, e);
|
||||
continue;
|
||||
}
|
||||
rules = sheets[i].cssRules;
|
||||
}
|
||||
if (rules) {
|
||||
for(var r = rules.length-1; r >= 0; r--) {
|
||||
var selectorText = rules[r].selectorText;
|
||||
|
||||
@@ -496,7 +496,18 @@ var getCssSelectors = function(filter) {
|
||||
}
|
||||
var sheets = document.styleSheets;
|
||||
for(var i = 0; i < sheets.length; i++) {
|
||||
var rules = sheets[i].rules || sheets[i].cssRules;
|
||||
var rules;
|
||||
if (sheets[i].rules) {
|
||||
rules = sheets[i].rules;
|
||||
} else {
|
||||
//try...catch because Firefox not able to enumerate document.styleSheets[].cssRules[] for cross-domain stylesheets.
|
||||
try {
|
||||
rules = sheets[i].cssRules;
|
||||
} catch(e) {
|
||||
console.warn("Can't read the css rules of: " + sheets[i].href, e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (rules) {
|
||||
for(var r = 0; r < rules.length; r++) {
|
||||
var selectorText = rules[r].selectorText;
|
||||
|
||||
Reference in New Issue
Block a user