From 4d611b8e40d41711eff78cee1bc7326752406318 Mon Sep 17 00:00:00 2001 From: raythurnvoid <53383860+raythurnvoid@users.noreply.github.com> Date: Sun, 8 Jun 2025 23:58:02 +0100 Subject: [PATCH] Fix top-most derived in a chain of deriveds marked as MAYBE_DIRTY when executed from a snippet $.fallback --- .../svelte/src/internal/client/reactivity/deriveds.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/internal/client/reactivity/deriveds.js b/packages/svelte/src/internal/client/reactivity/deriveds.js index e9cea0df3e..33026e4039 100644 --- a/packages/svelte/src/internal/client/reactivity/deriveds.js +++ b/packages/svelte/src/internal/client/reactivity/deriveds.js @@ -183,8 +183,14 @@ export function update_derived(derived) { // cleanup function, or it will cache a stale value if (is_destroying_effect) return; - var status = - (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN; + // only mark unowned deriveds as MAYBE_DIRTY if they have dependencies, otherwise they + // must be clean regardless of the value of the skip_reaction flag value set for the previous_reaction + // because not marking a regular derived as CLEAN will cause incosistent state when chaining + // multiple derivides in which the top-most derived is marked MAYBE_DIRTY and all the ones that depends + // on it are instead marked as CLEAN causing issues with properly updating the UI when the source state + // is updated because the MAYBE_DIRTY derived is skipped and as a consequence also + // the other deriveds (aka its reactions) are skipped as well. + var status = (derived.f & UNOWNED) !== 0 && derived.deps !== null ? MAYBE_DIRTY : CLEAN; set_signal_status(derived, status); }