From a2e6553b7fa66835abce779fc25e8bef110151ca Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Tue, 14 Feb 2017 10:27:08 -0500 Subject: Prevent CSS stacking when changing themes (#5378) --- webapp/utils/utils.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 2fd7bf99b..40b049542 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -711,6 +711,17 @@ export function changeCss(className, classValue) { // Grab style sheet const styleSheet = styleEl.sheet; + const rules = styleSheet.cssRules || styleSheet.rules; + const style = classValue.substr(0, classValue.indexOf(':')); + const value = classValue.substr(classValue.indexOf(':') + 1); + + for (let i = 0; i < rules.length; i++) { + if (rules[i].selectorText === className) { + rules[i].style[style] = value; + return; + } + } + let mediaQuery = ''; if (className.indexOf('@media') >= 0) { mediaQuery = '}'; -- cgit v1.2.3-1-g7c22