File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
packages/svelte/src/internal/client/reactivity Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -584,6 +584,9 @@ function infinite_loop_guard() {
584584 }
585585}
586586
587+ /** @type {Effect[] | null } */
588+ export let eager_block_effects = null ;
589+
587590/**
588591 * @param {Array<Effect> } effects
589592 * @returns {void }
@@ -600,6 +603,8 @@ function flush_queued_effects(effects) {
600603 if ( ( effect . f & ( DESTROYED | INERT ) ) === 0 && is_dirty ( effect ) ) {
601604 var sv = schedule_version ;
602605
606+ eager_block_effects = [ ] ;
607+
603608 update_effect ( effect ) ;
604609
605610 // Effects with no dependencies or teardown do not get added to the effect tree.
@@ -619,14 +624,24 @@ function flush_queued_effects(effects) {
619624 }
620625 }
621626
627+ if ( eager_block_effects . length > 0 ) {
628+ for ( const e of eager_block_effects ) {
629+ update_effect ( e ) ;
630+ }
631+
632+ eager_block_effects = [ ] ;
633+ }
634+
622635 // if a state change in a user effect invalidates a _different_ effect,
623636 // abort and reschedule in case that effect now needs to be destroyed
624637 if ( schedule_version > sv && ( effect . f & USER_EFFECT ) !== 0 ) {
625- break ;
638+ // break;
626639 }
627640 }
628641 }
629642
643+ eager_block_effects = null ;
644+
630645 while ( i < length ) {
631646 schedule_effect ( effects [ i ++ ] ) ;
632647 }
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import * as e from '../errors.js';
3333import { legacy_mode_flag , tracing_mode_flag } from '../../flags/index.js' ;
3434import { get_stack , tag_proxy } from '../dev/tracing.js' ;
3535import { component_context , is_runes } from '../context.js' ;
36- import { Batch , schedule_effect } from './batch.js' ;
36+ import { Batch , eager_block_effects , schedule_effect } from './batch.js' ;
3737import { proxy } from '../proxy.js' ;
3838import { execute_derived } from './deriveds.js' ;
3939
@@ -340,7 +340,13 @@ function mark_reactions(signal, status) {
340340 if ( ( flags & DERIVED ) !== 0 ) {
341341 mark_reactions ( /** @type {Derived } */ ( reaction ) , MAYBE_DIRTY ) ;
342342 } else if ( not_dirty ) {
343- if ( ( flags & BLOCK_EFFECT ) !== 0 ) schedule_version += 1 ;
343+ if ( ( flags & BLOCK_EFFECT ) !== 0 ) {
344+ if ( eager_block_effects !== null ) {
345+ eager_block_effects . push ( /** @type {Effect } */ ( reaction ) ) ;
346+ }
347+ schedule_version += 1 ;
348+ }
349+
344350 schedule_effect ( /** @type {Effect } */ ( reaction ) ) ;
345351 }
346352 }
You can’t perform that action at this time.
0 commit comments