diff --git a/src/js/colorModeJS.js b/src/js/colorModeJS.js index 3c495cdb5229aa5ffa74cd92fb3820adc9554b35..a9f57c5981134b898f9893c0bf14578d64135899 100644 --- a/src/js/colorModeJS.js +++ b/src/js/colorModeJS.js @@ -12,28 +12,32 @@ window.setColors = function(colorMap) { let props = ["color", "backgroundColor", "backgroundImage"]; let styleSheetArray = Array.from(document.styleSheets); styleSheetArray.forEach(styleSheet => { - let cssRules = Array.from(styleSheet.cssRules); - cssRules.forEach(cssRule => { - if (cssRule.type === 1) { - props.forEach(propName => { - let currentValue = cssRule.style[propName]; - if ( - currentValue !== "" && - currentValue !== "inherit" && - currentValue !== "transparent") { - let newVal = colorMap[currentValue]; - if (typeof newVal !== "undefined") { - cssRule.style[propName] = newVal; - originalState.push({ - element: cssRule, - propName: propName, - value: currentValue - }); + try { + let cssRules = Array.from(styleSheet.cssRules); + cssRules.forEach(cssRule => { + if (cssRule.type === 1) { + props.forEach(propName => { + let currentValue = cssRule.style[propName]; + if ( + currentValue !== "" && + currentValue !== "inherit" && + currentValue !== "transparent") { + let newVal = colorMap[currentValue]; + if (typeof newVal !== "undefined") { + cssRule.style[propName] = newVal; + originalState.push({ + element: cssRule, + propName: propName, + value: currentValue + }); + } } - } - }); - } - }); + }); + } + }); + } catch (error) { + // No need to do anthing, this is expected when there are user style sheets. + } }); return originalState; };