refactor(woodPanelingInit): simplify by removing DOMContentLoaded check
Since main.js has 'defer', the script executes after DOM is parsed. The DOMContentLoaded check was unnecessary - the else branch always executes. Simplified to just run immediately.
This commit is contained in:
@@ -7,21 +7,11 @@ const WOOD_INIT_STORAGE_KEY = "wood-paneling";
|
|||||||
(function () {
|
(function () {
|
||||||
const woodPaneling = localStorage.getItem(WOOD_INIT_STORAGE_KEY) || "none";
|
const woodPaneling = localStorage.getItem(WOOD_INIT_STORAGE_KEY) || "none";
|
||||||
if (woodPaneling !== "none") {
|
if (woodPaneling !== "none") {
|
||||||
const applyPaneling = () => {
|
const container = document.getElementById("collections-container");
|
||||||
const container = document.getElementById("collections-container");
|
if (container) {
|
||||||
if (container) {
|
container.classList.add(`bg-${woodPaneling}`);
|
||||||
container.classList.add(`bg-${woodPaneling}`);
|
container.setAttribute("data-wood", woodPaneling);
|
||||||
container.setAttribute("data-wood", woodPaneling);
|
document.body.classList.add(`bg-${woodPaneling}`);
|
||||||
|
|
||||||
document.body.classList.add(`bg-${woodPaneling}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply immediately if DOM is ready, otherwise wait
|
|
||||||
if (document.readyState === "loading") {
|
|
||||||
document.addEventListener("DOMContentLoaded", applyPaneling);
|
|
||||||
} else {
|
|
||||||
applyPaneling();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user