Skip to content
Snippets Groups Projects
Commit 2574bdd3 authored by Arkerthan's avatar Arkerthan
Browse files

force reloading stylesheets

parent 0e125265
No related branches found
No related tags found
No related merge requests found
...@@ -45,10 +45,7 @@ App.UI.Theme = (function() { ...@@ -45,10 +45,7 @@ App.UI.Theme = (function() {
*/ */
function load(filename) { function load(filename) {
V.theme = filename; V.theme = filename;
currentThemeElement = newTheme(filename); currentThemeElement = newTheme(filename);
document.head.appendChild(currentThemeElement);
} }
function unload() { function unload() {
...@@ -71,16 +68,22 @@ App.UI.Theme = (function() { ...@@ -71,16 +68,22 @@ App.UI.Theme = (function() {
if (filename !== undefined) { if (filename !== undefined) {
devTheme = newTheme(filename); devTheme = newTheme(filename);
// make it unique to force reloading instead of using the cached version
document.head.appendChild(devTheme); devTheme.href += `?id=${Date.now()}`;
} }
} }
/**
* Creates an new theme and adds it to the head element
* @param {string} filename
* @returns {HTMLLinkElement}
*/
function newTheme(filename) { function newTheme(filename) {
const theme = document.createElement("link"); const theme = document.createElement("link");
theme.setAttribute("rel", "stylesheet"); theme.setAttribute("rel", "stylesheet");
theme.setAttribute("type", "text/css"); theme.setAttribute("type", "text/css");
theme.setAttribute("href", `./${filename}`); theme.setAttribute("href", `./${filename}`);
document.head.appendChild(theme);
return theme; return theme;
} }
......
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