summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web_editor/static/src/js')
-rw-r--r--addons/web_editor/static/src/js/transcoder.js14
-rw-r--r--addons/web_editor/static/src/js/widgets.js13
2 files changed, 25 insertions, 2 deletions
diff --git a/addons/web_editor/static/src/js/transcoder.js b/addons/web_editor/static/src/js/transcoder.js
index 6e0097ee8fb..8dbc0ff0104 100644
--- a/addons/web_editor/static/src/js/transcoder.js
+++ b/addons/web_editor/static/src/js/transcoder.js
@@ -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;
diff --git a/addons/web_editor/static/src/js/widgets.js b/addons/web_editor/static/src/js/widgets.js
index 5926429fe73..87d985f19f4 100644
--- a/addons/web_editor/static/src/js/widgets.js
+++ b/addons/web_editor/static/src/js/widgets.js
@@ -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;