[FIX] reactivity: fix memory leak

The reactive cache should be a WeakMap from targets to another WeakMap
that associates callbacks to target. The second WeakMap was in fact a
map, and typescript did not complain because Map has compatible typing
with WeakMap. This commit fixes that.
This commit is contained in:
Samuel Degueldre
2022-05-13 11:19:48 +02:00
parent 5c71744e19
commit a83731007a
+1 -1
View File
@@ -207,7 +207,7 @@ export function reactive<T extends Target>(
return reactive(originalTarget, callback);
}
if (!reactiveCache.has(target)) {
reactiveCache.set(target, new Map());
reactiveCache.set(target, new WeakMap());
}
const reactivesForTarget = reactiveCache.get(target)!;
if (!reactivesForTarget.has(callback)) {