From 656df5c7615a94eccc4c7b59e8c63dc989a84391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6=E8=BF=9C=E6=96=B9?= Date: Sun, 18 Jun 2023 02:03:07 +0800 Subject: [PATCH] chore: replace Map by WeakMap (#2499) --- src/client/app/composables/copyCode.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/client/app/composables/copyCode.ts b/src/client/app/composables/copyCode.ts index 8d3afb52..1b679359 100644 --- a/src/client/app/composables/copyCode.ts +++ b/src/client/app/composables/copyCode.ts @@ -2,13 +2,12 @@ import { inBrowser } from 'vitepress' export function useCopyCode() { if (inBrowser) { - const timeoutIdMap: Map = new Map() + const timeoutIdMap: WeakMap = new WeakMap() window.addEventListener('click', (e) => { const el = e.target as HTMLElement if (el.matches('div[class*="language-"] > button.copy')) { const parent = el.parentElement - const sibling = el.nextElementSibling - ?.nextElementSibling as HTMLPreElement | null + const sibling = el.nextElementSibling?.nextElementSibling if (!parent || !sibling) { return }