Skip to content

Node.js based forum software built for the modern web

fix: #7176, FUOC on app.reskin()

Julian Lam954af0f0d24c
diff --git a/public/src/app.js b/public/src/app.js
index 74a006b29e..f7d7ec4510 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -764,15 +764,24 @@ app.cacheBuster = null;
if (!clientEl) {
return;
}
- // Update client.css link element to point to selected skin variant
- clientEl.href = config.relative_path + '/assets/client' + (skinName ? '-' + skinName : '') + '.css';
- var currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
- return className.startsWith('skin-');
- });
- $('body').removeClass(currentSkinClassName.join(' '));
- if (skinName) {
- $('body').addClass('skin-' + skinName);
- }
+ var linkEl = document.createElement('link');
+ linkEl.rel = 'stylesheet';
+ linkEl.type = 'text/css';
+ linkEl.href = config.relative_path + '/assets/client' + (skinName ? '-' + skinName : '') + '.css';
+ linkEl.onload = function () {
+ clientEl.parentNode.removeChild(clientEl);
+
+ // Update body class with proper skin name
+ var currentSkinClassName = $('body').attr('class').split(/\s+/).filter(function (className) {
+ return className.startsWith('skin-');
+ });
+ $('body').removeClass(currentSkinClassName.join(' '));
+ if (skinName) {
+ $('body').addClass('skin-' + skinName);
+ }
+ };
+
+ document.head.appendChild(linkEl);
};
}());