Skip to content

Commit

Permalink
fix: ensure unowned deriveds correctly get re-linked to the graph
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Dec 28, 2024
1 parent 7f8acb8 commit 9285e7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-dolphins-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: ensure unowned deriveds correctly get re-linked to the graph
12 changes: 10 additions & 2 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,12 @@ export function check_dirtiness(reaction) {
reaction.f ^= DISCONNECTED;
}

var dirty = false;

for (i = 0; i < dependencies.length; i++) {
var dependency = dependencies[i];

if (check_dirtiness(/** @type {Derived} */ (dependency))) {
if (!dirty && check_dirtiness(/** @type {Derived} */ (dependency))) {
update_derived(/** @type {Derived} */ (dependency));
}

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

if (dependency.version > reaction.version) {
return true;
// We can't just return here as we might have other dependencies that are unowned
// ad need to be linked to the reaction again
dirty = true;
}
}

if (dirty) {
return true;
}
}

// Unowned signals should never be marked as clean unless they
Expand Down

0 comments on commit 9285e7b

Please sign in to comment.