mirror of
https://github.com/alrayyes/wiki.git
synced 2025-06-06 05:53:14 +00:00
chore: add window.addCleanup() for cleaning up handlers
This commit is contained in:
parent
8a6ebd1939
commit
c00089bd57
12 changed files with 47 additions and 49 deletions
quartz/components/scripts
|
@ -19,8 +19,8 @@ document.addEventListener("nav", () => {
|
|||
|
||||
// Darkmode toggle
|
||||
const toggleSwitch = document.querySelector("#darkmode-toggle") as HTMLInputElement
|
||||
toggleSwitch.removeEventListener("change", switchTheme)
|
||||
toggleSwitch.addEventListener("change", switchTheme)
|
||||
window.addCleanup(() => toggleSwitch.removeEventListener("change", switchTheme))
|
||||
if (currentTheme === "dark") {
|
||||
toggleSwitch.checked = true
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue