@@ -516,8 +516,27 @@ function infinite_loop_guard() {
516
516
*/
517
517
function flush_queued_root_effects ( root_effects ) {
518
518
infinite_loop_guard ( ) ;
519
- for ( var i = 0 ; i < root_effects . length ; i ++ ) {
520
- flush_nested_effects ( root_effects [ i ] ) ;
519
+
520
+ var previously_flushing_effect = is_flushing_effect ;
521
+ is_flushing_effect = true ;
522
+
523
+ try {
524
+ for ( var i = 0 ; i < root_effects . length ; i ++ ) {
525
+ var effect = root_effects [ i ] ;
526
+
527
+ // When working with custom elements, the root effects might not have a root
528
+ if ( effect . first === null && ( effect . f & BRANCH_EFFECT ) === 0 ) {
529
+ flush_queued_effects ( [ effect ] ) ;
530
+ } else {
531
+ /** @type {import('#client').Effect[] } */
532
+ var collected_effects = [ ] ;
533
+
534
+ process_effects ( effect , collected_effects ) ;
535
+ flush_queued_effects ( collected_effects ) ;
536
+ }
537
+ }
538
+ } finally {
539
+ is_flushing_effect = previously_flushing_effect ;
521
540
}
522
541
}
523
542
@@ -586,11 +605,10 @@ export function schedule_effect(signal) {
586
605
* effects to be flushed.
587
606
*
588
607
* @param {import('#client').Effect } effect
589
- * @param {boolean } recursive
590
608
* @param {import('#client').Effect[] } collected_effects
591
609
* @returns {void }
592
610
*/
593
- function process_effects ( effect , recursive , collected_effects ) {
611
+ function process_effects ( effect , collected_effects ) {
594
612
var current_effect = effect . first ;
595
613
var effects = [ ] ;
596
614
@@ -614,13 +632,14 @@ function process_effects(effect, recursive, collected_effects) {
614
632
// Child might have been mutated since running the effect
615
633
child = current_effect . first ;
616
634
}
617
- if ( recursive && child !== null ) {
635
+
636
+ if ( child !== null ) {
618
637
current_effect = child ;
619
638
continue ;
620
639
}
621
640
} else if ( ( flags & EFFECT ) !== 0 ) {
622
641
if ( is_branch || is_clean ) {
623
- if ( recursive && child !== null ) {
642
+ if ( child !== null ) {
624
643
current_effect = child ;
625
644
continue ;
626
645
}
@@ -650,58 +669,15 @@ function process_effects(effect, recursive, collected_effects) {
650
669
current_effect = sibling ;
651
670
}
652
671
653
- if ( recursive ) {
654
- // We might be dealing with many effects here, far more than can be spread into
655
- // an array push call (callstack overflow). So let's deal with each effect in a loop.
656
- for ( var i = 0 ; i < effects . length ; i ++ ) {
657
- child = effects [ i ] ;
658
- collected_effects . push ( child ) ;
659
- process_effects ( child , true , collected_effects ) ;
660
- }
672
+ // We might be dealing with many effects here, far more than can be spread into
673
+ // an array push call (callstack overflow). So let's deal with each effect in a loop.
674
+ for ( var i = 0 ; i < effects . length ; i ++ ) {
675
+ child = effects [ i ] ;
676
+ collected_effects . push ( child ) ;
677
+ process_effects ( child , collected_effects ) ;
661
678
}
662
679
}
663
680
664
- /**
665
- *
666
- * This function recursively collects effects in topological order from the starting effect passed in.
667
- * Effects will be collected when they match the filtered bitwise flag passed in only. The collected
668
- * array will be populated with all the effects.
669
- *
670
- * @param {import('#client').Effect } effect
671
- * @param {boolean } [recursive]
672
- * @returns {void }
673
- */
674
- function flush_nested_effects ( effect , recursive = true ) {
675
- var previously_flushing_effect = is_flushing_effect ;
676
- is_flushing_effect = true ;
677
-
678
- try {
679
- // When working with custom elements, the root effects might not have a root
680
- if ( effect . first === null && ( effect . f & BRANCH_EFFECT ) === 0 ) {
681
- flush_queued_effects ( [ effect ] ) ;
682
- } else {
683
- /** @type {import('#client').Effect[] } */
684
- var collected_effects = [ ] ;
685
-
686
- process_effects ( effect , recursive , collected_effects ) ;
687
- flush_queued_effects ( collected_effects ) ;
688
- }
689
- } finally {
690
- is_flushing_effect = previously_flushing_effect ;
691
- }
692
- }
693
-
694
- /**
695
- * @param {import('#client').Effect } effect
696
- * @returns {void }
697
- */
698
- export function flush_local_render_effects ( effect ) {
699
- infinite_loop_guard ( ) ;
700
- // We are entering a new flush sequence, so ensure counter is reset.
701
- flush_count = 0 ;
702
- flush_nested_effects ( effect , false ) ;
703
- }
704
-
705
681
/**
706
682
* Internal version of `flushSync` with the option to not flush previous effects.
707
683
* Returns the result of the passed function, if given.
0 commit comments