Skip to content
Snippets Groups Projects
Commit 80836f4b authored by Arkerthan's avatar Arkerthan
Browse files

user themes cannot be modified via JS

parent 786acd16
No related branches found
No related tags found
1 merge request!6675Fix flip lightning with user themes
......@@ -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;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment