chore: add window.addCleanup() for cleaning up handlers

This commit is contained in:
Jacky Zhao committed 2024-02-01 21:19:51 -08:00
1 parent 8a6ebd1939
commit c00089bd57
12 files changed
+47 -49

No files matched your search

+1 -1
View File
@@ -29,8 +29,8 @@ function setupToc() {
const content = toc.nextElementSibling as HTMLElement | undefined
if (!content) return
content.style.maxHeight = collapsed ? "0px" : content.scrollHeight + "px"
toc.removeEventListener("click", toggleToc)
toc.addEventListener("click", toggleToc)
window.addCleanup(() => toc.removeEventListener("click", toggleToc))
}
}