Skip to content

Commit 4d611b8

Browse files
committed
Fix top-most derived in a chain of deriveds marked as MAYBE_DIRTY when executed from a snippet $.fallback
1 parent 26e3286 commit 4d611b8

File tree

1 file changed

+8
-2
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+8
-2
lines changed

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,14 @@ export function update_derived(derived) {
183183
// cleanup function, or it will cache a stale value
184184
if (is_destroying_effect) return;
185185

186-
var status =
187-
(skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
186+
// only mark unowned deriveds as MAYBE_DIRTY if they have dependencies, otherwise they
187+
// must be clean regardless of the value of the skip_reaction flag value set for the previous_reaction
188+
// because not marking a regular derived as CLEAN will cause incosistent state when chaining
189+
// multiple derivides in which the top-most derived is marked MAYBE_DIRTY and all the ones that depends
190+
// on it are instead marked as CLEAN causing issues with properly updating the UI when the source state
191+
// is updated because the MAYBE_DIRTY derived is skipped and as a consequence also
192+
// the other deriveds (aka its reactions) are skipped as well.
193+
var status = (derived.f & UNOWNED) !== 0 && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
188194

189195
set_signal_status(derived, status);
190196
}

0 commit comments

Comments
 (0)