From 2574bdd39120a40d91f3c207c0dd9eb43683f04d Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Wed, 10 Jun 2020 22:09:11 +0200 Subject: [PATCH] force reloading stylesheets --- src/gui/theming.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/theming.js b/src/gui/theming.js index 038a21fcf6d..08bf7e627f8 100644 --- a/src/gui/theming.js +++ b/src/gui/theming.js @@ -45,10 +45,7 @@ App.UI.Theme = (function() { */ function load(filename) { V.theme = filename; - currentThemeElement = newTheme(filename); - - document.head.appendChild(currentThemeElement); } function unload() { @@ -71,16 +68,22 @@ App.UI.Theme = (function() { if (filename !== undefined) { devTheme = newTheme(filename); - - document.head.appendChild(devTheme); + // make it unique to force reloading instead of using the cached version + devTheme.href += `?id=${Date.now()}`; } } + /** + * Creates an new theme and adds it to the head element + * @param {string} filename + * @returns {HTMLLinkElement} + */ function newTheme(filename) { const theme = document.createElement("link"); theme.setAttribute("rel", "stylesheet"); theme.setAttribute("type", "text/css"); theme.setAttribute("href", `./${filename}`); + document.head.appendChild(theme); return theme; } -- GitLab