File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 11/** @import { Effect, Source } from '#client' */
22import { DIRTY } from '#client/constants' ;
3- import { noop } from '../../shared/utils.js' ;
4- import { flushSync } from '../runtime.js' ;
3+ import { schedule_effect , set_signal_status } from '../runtime.js' ;
54import { raf } from '../timing.js' ;
65import { internal_set , mark_reactions , pending } from './sources.js' ;
76
@@ -31,6 +30,9 @@ export class Batch {
3130 /** @type {Map<Source, any> } */
3231 #current = new Map ( ) ;
3332
33+ /** @type {Set<Effect> } */
34+ effects = new Set ( ) ;
35+
3436 /** @type {Set<Effect> } */
3537 skipped_effects = new Set ( ) ;
3638
@@ -49,6 +51,13 @@ export class Batch {
4951 source . v = current ;
5052 }
5153
54+ for ( const e of this . effects ) {
55+ if ( e . fn ) {
56+ set_signal_status ( e , DIRTY ) ;
57+ schedule_effect ( e ) ;
58+ }
59+ }
60+
5261 for ( const batch of batches ) {
5362 if ( batch === this ) continue ;
5463
Original file line number Diff line number Diff line change @@ -718,6 +718,18 @@ function flush_queued_root_effects() {
718718 batch . commit ( ) ;
719719 flush_queued_effects ( render_effects ) ;
720720 flush_queued_effects ( effects ) ;
721+ } else {
722+ // store the effects on the batch so that they run next time,
723+ // even if they don't get re-dirtied
724+ for ( const e of render_effects ) {
725+ batch . effects . add ( e ) ;
726+ set_signal_status ( e , CLEAN ) ;
727+ }
728+
729+ for ( const e of effects ) {
730+ batch . effects . add ( e ) ;
731+ set_signal_status ( e , CLEAN ) ;
732+ }
721733 }
722734
723735 revert ( ) ;
You can’t perform that action at this time.
0 commit comments