diff options
| author | Mohammed Shekha <msh@openerp.com> | 2015-07-23 14:35:02 +0530 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-07-31 10:15:56 +0200 |
| commit | d434500ec8b9d5da0c341f3e6d6748a4bb7c6e2e (patch) | |
| tree | 644e3db4a53bec68601294f7734d56a6fc2201ef /addons/web_editor/static/src/js/transcoder.js | |
| parent | 5a4c8998e7c04291927aadbb349b573d63d19203 (diff) | |
[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
Diffstat (limited to 'addons/web_editor/static/src/js/transcoder.js')
| -rw-r--r-- | addons/web_editor/static/src/js/transcoder.js | 14 |
1 files changed, 13 insertions, 1 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; |
