File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 1 file changed +14
-4
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,8 +384,15 @@ export function update_derived(derived) {
381384 if ( effect_tracking ( ) || current_batch ?. is_fork ) {
382385 batch_values . set ( derived , value ) ;
383386 }
384- } else {
385- var status = ( derived . f & CONNECTED ) === 0 ? MAYBE_DIRTY : CLEAN ;
386- set_signal_status ( derived , status ) ;
387+ }
388+
389+ // Only mark as MAYBE_DIRTY if disconnected AND has dependencies.
390+ // Deriveds with no deps can never become dirty from dependency changes.
391+ if ( batch_values === null || derived . deps === null ) {
392+ if ( ( derived . f & CONNECTED ) === 0 && derived . deps !== null ) {
393+ set_signal_status ( derived , MAYBE_DIRTY ) ;
394+ } else {
395+ set_signal_status ( derived , CLEAN ) ;
396+ }
387397 }
388398}
You can’t perform that action at this time.
0 commit comments