We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a547530 commit 656df5cCopy full SHA for 656df5c
src/client/app/composables/copyCode.ts
@@ -2,13 +2,12 @@ import { inBrowser } from 'vitepress'
2
3
export function useCopyCode() {
4
if (inBrowser) {
5
- const timeoutIdMap: Map<HTMLElement, NodeJS.Timeout> = new Map()
+ const timeoutIdMap: WeakMap<HTMLElement, NodeJS.Timeout> = new WeakMap()
6
window.addEventListener('click', (e) => {
7
const el = e.target as HTMLElement
8
if (el.matches('div[class*="language-"] > button.copy')) {
9
const parent = el.parentElement
10
- const sibling = el.nextElementSibling
11
- ?.nextElementSibling as HTMLPreElement | null
+ const sibling = el.nextElementSibling?.nextElementSibling
12
if (!parent || !sibling) {
13
return
14
}
0 commit comments