Commit a1ec6e4
Fix cross-domain cssRules access breaking code (#214)
When @import rule points to an other domain, accessing the style sheet with .cssRules will cause trouble on Chrome and Firefox (at least, haven't tested on other browsers). Firefox will raise a "Security error code: 1000" while Chrome will raise "Uncaught DOMException: Failed to read the 'cssRules' property from 'CSSStyleSheet': Cannot access rules" which (I d'ont know why) can't be caught with a regular try catch statement and will break the for loop and thus not parse the other rules if any.
I had this problem while having a @import rule for google fonts. I fixed the issue by checking first if the property cssRules actually exist.1 parent 3817e42 commit a1ec6e4
1 file changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
387 | | - | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
388 | 390 | | |
389 | 391 | | |
390 | 392 | | |
| |||
0 commit comments