Skip to content

Commit

Permalink
more error-prone check of cssRules existence before css variables are…
Browse files Browse the repository at this point in the history
… get from stylesheet

DSpace#2450
  • Loading branch information
floriangantner committed Oct 26, 2023
1 parent 11125ec commit 7f8e887
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/shared/sass-helper/css-variable.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ export class CSSVariableService {
* @param styleSheet The stylesheet
*/
hasCssRules = (styleSheet) => {
// Injected styles might have no css rules value
return styleSheet.hasOwnProperty('cssRules') && styleSheet.cssRules;
// Injected (cross-origin) styles might have no css rules value and throw some exception
try {
return styleSheet.cssRules;
} catch (e) {
return false;
}
};

/*
Expand Down

0 comments on commit 7f8e887

Please sign in to comment.