Skip to content

Commit 9e78a99

Browse files
committed
Avoid installing global keydown handler more than once
1 parent eadb3cd commit 9e78a99

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

quote-selection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export function subscribe(container: Element): Subscription {
2121
}
2222

2323
export function install(container: Element) {
24+
const firstInstall = installed === 0
2425
installed += containers.has(container) ? 0 : 1
2526
containers.set(container, 1)
26-
document.addEventListener('keydown', quoteSelection)
27+
if (firstInstall) {
28+
document.addEventListener('keydown', quoteSelection)
29+
}
2730
if (!edgeBrowser) {
2831
container.addEventListener('copy', onCopy)
2932
}

0 commit comments

Comments
 (0)