0

I'm seeing the below errors in my website, its seems related to cross-domain support but not able to resolve. Can anyone suggest me how to resolve this issue?

Error:

Uncaught DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules
    at addRule 
jinfy
  • 147
  • 1
  • 12
  • 3
    And the code causing the error is a state level secret, and can't be shown? – Teemu Mar 30 '18 at 07:07
  • 1
    Possible duplicate of [Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet'](https://stackoverflow.com/questions/49161159/uncaught-domexception-failed-to-read-the-rules-property-from-cssstylesheet) – leventov May 15 '18 at 14:36

1 Answers1

0

In case anyone else has this issue related to the Cross-Origin Resource Sharing (CORS) policy it is discussed here: https://github.com/Modernizr/Modernizr/issues/2296

You will have to test using a local host: https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server

Here is the workaround a "try/catch" method:

try {
  var classes = stylesheets[s].rules || stylesheets[s].cssRules;
} catch (e) {
  console.warn("Can't read the css rules of: " + stylesheets[s].href, e);
  continue
}

Had this issue and was racking my brain and this seemed to work...Good luck!

Omnichief
  • 66
  • 5