Skip to content

Commit 47bad43

Browse files
authored
fix: use WeakMap to avoid memory leak (#463)
IntersectionObserver roots were tracked in a Map. This ensures it's possible to reuse the Intersection Observer instance if they share the same options. Changed to use a WeakMap, so unused root elements can be garbage collected. Closes #462
1 parent b703489 commit 47bad43

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/observers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const ObserverMap = new Map<
99
}
1010
>();
1111

12-
const RootIds: Map<Element, string> = new Map();
12+
const RootIds: WeakMap<Element, string> = new WeakMap();
1313

1414
let rootId = 0;
1515

0 commit comments

Comments
 (0)