function checkForParentTheme(element, theme) { let parent = element.parentElement; while (parent) { //if (parent.classList.contains("target")) { const parentTheme = parent.getAttribute("theme"); //if (!parentTheme) return false; if (parentTheme) return parentTheme !== theme; //} parent = parent.parentElement; } return false; } export function main(target, initialTheme = null) { const storedTheme = localStorage.getItem("theme"); let theme = initialTheme || storedTheme || "blackboard"; target.setAttribute("theme", theme); if (target === document.body) { localStorage.setItem("theme", theme); } if (checkForParentTheme(target, theme)) { target.setAttribute("theme-changed", ""); } else { target.removeAttribute("theme-changed"); } return { replace: false }; }