From 786acd16684cbef63d8f7761722f9409b98ebc68 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Fri, 24 Apr 2020 20:47:45 +0200 Subject: [PATCH] do not load theme if V.theme === undefined --- src/gui/theming.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gui/theming.js b/src/gui/theming.js index fa248354326..038a21fcf6d 100644 --- a/src/gui/theming.js +++ b/src/gui/theming.js @@ -7,7 +7,7 @@ App.UI.Theme = (function() { // reload theme on page reload $(document).on(":passagestart", () => { - if (currentThemeElement === null && V.theme !== 0) { + if (currentThemeElement === null && V.theme !== 0 && V.theme !== undefined) { load(V.theme); } }); @@ -46,10 +46,7 @@ App.UI.Theme = (function() { function load(filename) { V.theme = filename; - currentThemeElement = document.createElement("link"); - currentThemeElement.setAttribute("rel", "stylesheet"); - currentThemeElement.setAttribute("type", "text/css"); - currentThemeElement.setAttribute("href", `./${filename}`); + currentThemeElement = newTheme(filename); document.head.appendChild(currentThemeElement); } @@ -72,16 +69,21 @@ App.UI.Theme = (function() { devTheme = null; } - if (name !== undefined) { - devTheme = document.createElement("link"); - devTheme.setAttribute("rel", "stylesheet"); - devTheme.setAttribute("type", "text/css"); - devTheme.setAttribute("href", `./${filename}`); + if (filename !== undefined) { + devTheme = newTheme(filename); document.head.appendChild(devTheme); } } + function newTheme(filename) { + const theme = document.createElement("link"); + theme.setAttribute("rel", "stylesheet"); + theme.setAttribute("type", "text/css"); + theme.setAttribute("href", `./${filename}`); + return theme; + } + /** * @param {object} V */ -- GitLab