mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
check cssRules existence before css variables are get from stylesheet
(cherry picked from commit 367cda2de0
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
fd850164f5
commit
c4a60abd65
@@ -26,6 +26,17 @@ export class CSSVariableService {
|
|||||||
return styleSheet.href.indexOf(window.location.origin) === 0;
|
return styleSheet.href.indexOf(window.location.origin) === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the specific stylesheet object has the property cssRules
|
||||||
|
* @param styleSheet The stylesheet
|
||||||
|
*/
|
||||||
|
hasCssRules = (styleSheet) => {
|
||||||
|
// Injected styles might have no css rules value
|
||||||
|
return styleSheet.hasOwnProperty('cssRules') && styleSheet.cssRules;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Determine if the given rule is a CSSStyleRule
|
Determine if the given rule is a CSSStyleRule
|
||||||
See: https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
|
See: https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
|
||||||
@@ -93,8 +104,10 @@ export class CSSVariableService {
|
|||||||
if (isNotEmpty(document.styleSheets)) {
|
if (isNotEmpty(document.styleSheets)) {
|
||||||
// styleSheets is array-like, so we convert it to an array.
|
// styleSheets is array-like, so we convert it to an array.
|
||||||
// Filter out any stylesheets not on this domain
|
// Filter out any stylesheets not on this domain
|
||||||
|
// Filter out any stylesheets that have no cssRules property
|
||||||
return [...document.styleSheets]
|
return [...document.styleSheets]
|
||||||
.filter(this.isSameDomain)
|
.filter(this.isSameDomain)
|
||||||
|
.filter(this.hasCssRules)
|
||||||
.reduce(
|
.reduce(
|
||||||
(finalArr, sheet) =>
|
(finalArr, sheet) =>
|
||||||
finalArr.concat(
|
finalArr.concat(
|
||||||
|
Reference in New Issue
Block a user