Skip to content

Commit

Permalink
fix: ensure SvelteMap reactivity persists through deriveds
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Oct 24, 2024
1 parent 48477c9 commit 961044f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/svelte/src/reactivity/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ export class SvelteMap extends Map {
increment(version);
} else if (prev_res !== value) {
increment(s);
// If no one listening to this property yet, but version is
// being listened to, then also increment version to keep
// those cases in sync
if (s.reactions === null || version.reactions === null) {
// If no one listening to this property and is listening to the version, or
// the inverse, then we should increment the version to be safe
if (
(s.reactions === null && version.reactions !== null) ||
(s.reactions !== null && version.reactions === null)
) {
increment(version);
}
}
Expand Down

0 comments on commit 961044f

Please sign in to comment.