File tree Expand file tree Collapse file tree
src/app/shared/sass-helper Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,19 @@ export class CSSVariableService {
2626 return styleSheet . href . indexOf ( window . location . origin ) === 0 ;
2727 } ;
2828
29+ /**
30+ * Checks whether the specific stylesheet object has the property cssRules
31+ * @param styleSheet The stylesheet
32+ */
33+ hasCssRules = ( styleSheet ) => {
34+ // Injected (cross-origin) styles might have no css rules value and throw some exception
35+ try {
36+ return styleSheet . cssRules ;
37+ } catch ( e ) {
38+ return false ;
39+ }
40+ } ;
41+
2942 /*
3043 Determine if the given rule is a CSSStyleRule
3144 See: https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
@@ -93,8 +106,10 @@ export class CSSVariableService {
93106 if ( isNotEmpty ( document . styleSheets ) ) {
94107 // styleSheets is array-like, so we convert it to an array.
95108 // Filter out any stylesheets not on this domain
109+ // Filter out any stylesheets that have no cssRules property
96110 return [ ...document . styleSheets ]
97111 . filter ( this . isSameDomain )
112+ . filter ( this . hasCssRules )
98113 . reduce (
99114 ( finalArr , sheet ) =>
100115 finalArr . concat (
You can’t perform that action at this time.
0 commit comments