diff --git a/.changeset/chatty-dolphins-complain.md b/.changeset/chatty-dolphins-complain.md new file mode 100644 index 0000000000..b2c6f2b971 --- /dev/null +++ b/.changeset/chatty-dolphins-complain.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: ensure unowned deriveds correctly get re-linked to the graph diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 4a90a21971..98aba8a2f0 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -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)); } @@ -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