chore(cleanup): misc refactoring for cleanup, fix some search bugs

This commit is contained in:
Jacky Zhao
2024-02-01 23:55:11 -08:00
parent 45b93a80f4
commit 9b8e0c9d1a
4 changed files with 102 additions and 173 deletions

View File

@ -14,7 +14,7 @@ document.addEventListener("nav", () => {
button.type = "button"
button.innerHTML = svgCopy
button.ariaLabel = "Copy source"
button.addEventListener("click", () => {
function onClick() {
navigator.clipboard.writeText(source).then(
() => {
button.blur()
@ -26,7 +26,9 @@ document.addEventListener("nav", () => {
},
(error) => console.error(error),
)
})
}
button.addEventListener("click", onClick)
window.addCleanup(() => button.removeEventListener("click", onClick))
els[i].prepend(button)
}
}