File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff 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 ) ;
You can’t perform that action at this time.
0 commit comments