Skip to content

Commit 656df5c

Browse files
chore: replace Map by WeakMap (#2499)
1 parent a547530 commit 656df5c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/client/app/composables/copyCode.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { inBrowser } from 'vitepress'
22

33
export function useCopyCode() {
44
if (inBrowser) {
5-
const timeoutIdMap: Map<HTMLElement, NodeJS.Timeout> = new Map()
5+
const timeoutIdMap: WeakMap<HTMLElement, NodeJS.Timeout> = new WeakMap()
66
window.addEventListener('click', (e) => {
77
const el = e.target as HTMLElement
88
if (el.matches('div[class*="language-"] > button.copy')) {
99
const parent = el.parentElement
10-
const sibling = el.nextElementSibling
11-
?.nextElementSibling as HTMLPreElement | null
10+
const sibling = el.nextElementSibling?.nextElementSibling
1211
if (!parent || !sibling) {
1312
return
1413
}

0 commit comments

Comments
 (0)