diff --git a/src/theme.js b/src/theme.js index da70dc7bb1..7e0eaabf11 100644 --- a/src/theme.js +++ b/src/theme.js @@ -35,6 +35,16 @@ export function enumerateThemes() { return Object.assign({}, customThemeNames, BUILTIN_THEMES); } +function clearCustomTheme() { + // remove all css variables, we assume these are there because of the custom theme + const inlineStyleProps = Object.values(document.body.style); + for (const prop of inlineStyleProps) { + if (prop.startsWith("--")) { + document.body.style.removeProperty(prop); + } + } +} + function setCustomThemeVars(customTheme) { const {style} = document.body; @@ -97,6 +107,7 @@ export async function setTheme(theme) { const themeWatcher = new ThemeWatcher(); theme = themeWatcher.getEffectiveTheme(); } + clearCustomTheme(); let stylesheetName = theme; if (theme.startsWith("custom-")) { const customTheme = getCustomTheme(theme.substr(7));