File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/app/shared/sass-helper Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ 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 styles might have no css rules value
35+ return styleSheet . hasOwnProperty ( 'cssRules' ) && styleSheet . cssRules ;
36+ } ;
37+
2938 /*
3039 Determine if the given rule is a CSSStyleRule
3140 See: https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
@@ -93,8 +102,10 @@ export class CSSVariableService {
93102 if ( isNotEmpty ( document . styleSheets ) ) {
94103 // styleSheets is array-like, so we convert it to an array.
95104 // Filter out any stylesheets not on this domain
105+ // Filter out any stylesheets that have no cssRules property
96106 return [ ...document . styleSheets ]
97107 . filter ( this . isSameDomain )
108+ . filter ( this . hasCssRules )
98109 . reduce (
99110 ( finalArr , sheet ) =>
100111 finalArr . concat (
You can’t perform that action at this time.
0 commit comments