Skip to content

Commit 555628b

Browse files
committed
fix: maintain reactivity for properties of deriveds with no deps
fixes #17111, fixes #17352
1 parent 2cd6ddf commit 555628b

File tree

1 file changed

+9
-1
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,10 @@ export function update_derived(derived) {
360360
// the underlying value will be updated when the fork is committed.
361361
// otherwise, the next time we get here after a 'real world' state
362362
// change, `derived.equals` may incorrectly return `true`
363-
if (!current_batch?.is_fork) {
363+
//
364+
// deriveds with no deps should always update `derived.v`
365+
// since they will never change and need the value after fork commits
366+
if (!current_batch?.is_fork || derived.deps === null) {
364367
derived.v = value;
365368
}
366369

@@ -381,6 +384,11 @@ export function update_derived(derived) {
381384
if (effect_tracking() || current_batch?.is_fork) {
382385
batch_values.set(derived, value);
383386
}
387+
// For deriveds with no deps, set CLEAN to prevent re-evaluation
388+
// since they can never become dirty from dependency changes
389+
if (derived.deps === null) {
390+
set_signal_status(derived, CLEAN);
391+
}
384392
} else {
385393
var status = (derived.f & CONNECTED) === 0 ? MAYBE_DIRTY : CLEAN;
386394
set_signal_status(derived, status);

0 commit comments

Comments
 (0)