Skip to content

Commit 9285e7b

Browse files
committed
fix: ensure unowned deriveds correctly get re-linked to the graph
1 parent 7f8acb8 commit 9285e7b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure unowned deriveds correctly get re-linked to the graph

packages/svelte/src/internal/client/runtime.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,12 @@ export function check_dirtiness(reaction) {
205205
reaction.f ^= DISCONNECTED;
206206
}
207207

208+
var dirty = false;
209+
208210
for (i = 0; i < dependencies.length; i++) {
209211
var dependency = dependencies[i];
210212

211-
if (check_dirtiness(/** @type {Derived} */ (dependency))) {
213+
if (!dirty && check_dirtiness(/** @type {Derived} */ (dependency))) {
212214
update_derived(/** @type {Derived} */ (dependency));
213215
}
214216

@@ -225,9 +227,15 @@ export function check_dirtiness(reaction) {
225227
}
226228

227229
if (dependency.version > reaction.version) {
228-
return true;
230+
// We can't just return here as we might have other dependencies that are unowned
231+
// ad need to be linked to the reaction again
232+
dirty = true;
229233
}
230234
}
235+
236+
if (dirty) {
237+
return true;
238+
}
231239
}
232240

233241
// Unowned signals should never be marked as clean unless they

0 commit comments

Comments
 (0)