Skip to content

Commit 961044f

Browse files
committed
fix: ensure SvelteMap reactivity persists through deriveds
1 parent 48477c9 commit 961044f

File tree

1 file changed

+6
-4
lines changed
  • packages/svelte/src/reactivity

1 file changed

+6
-4
lines changed

packages/svelte/src/reactivity/map.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ export class SvelteMap extends Map {
102102
increment(version);
103103
} else if (prev_res !== value) {
104104
increment(s);
105-
// If no one listening to this property yet, but version is
106-
// being listened to, then also increment version to keep
107-
// those cases in sync
108-
if (s.reactions === null || version.reactions === null) {
105+
// If no one listening to this property and is listening to the version, or
106+
// the inverse, then we should increment the version to be safe
107+
if (
108+
(s.reactions === null && version.reactions !== null) ||
109+
(s.reactions !== null && version.reactions === null)
110+
) {
109111
increment(version);
110112
}
111113
}

0 commit comments

Comments
 (0)