@@ -521,9 +521,27 @@ function infinite_loop_guard() {
521
521
*/
522
522
function flush_queued_root_effects ( root_effects ) {
523
523
infinite_loop_guard ( ) ;
524
- for ( var i = 0 ; i < root_effects . length ; i ++ ) {
525
- var signal = root_effects [ i ] ;
526
- flush_nested_effects ( signal , RENDER_EFFECT | EFFECT ) ;
524
+
525
+ var previously_flushing_effect = is_flushing_effect ;
526
+ is_flushing_effect = true ;
527
+
528
+ try {
529
+ for ( var i = 0 ; i < root_effects . length ; i ++ ) {
530
+ var effect = root_effects [ i ] ;
531
+
532
+ // When working with custom elements, the root effects might not have a root
533
+ if ( effect . first === null && ( effect . f & BRANCH_EFFECT ) === 0 ) {
534
+ flush_queued_effects ( [ effect ] ) ;
535
+ } else {
536
+ /** @type {import('#client').Effect[] } */
537
+ var collected_effects = [ ] ;
538
+
539
+ process_effects ( effect , collected_effects ) ;
540
+ flush_queued_effects ( collected_effects ) ;
541
+ }
542
+ }
543
+ } finally {
544
+ is_flushing_effect = previously_flushing_effect ;
527
545
}
528
546
}
529
547
@@ -592,12 +610,10 @@ export function schedule_effect(signal) {
592
610
* effects to be flushed.
593
611
*
594
612
* @param {import('#client').Effect } effect
595
- * @param {number } filter_flags
596
- * @param {boolean } shallow
597
613
* @param {import('#client').Effect[] } collected_effects
598
614
* @returns {void }
599
615
*/
600
- function process_effects ( effect , filter_flags , shallow , collected_effects ) {
616
+ function process_effects ( effect , collected_effects ) {
601
617
var current_effect = effect . first ;
602
618
var effects = [ ] ;
603
619
@@ -621,13 +637,14 @@ function process_effects(effect, filter_flags, shallow, collected_effects) {
621
637
// Child might have been mutated since running the effect
622
638
child = current_effect . first ;
623
639
}
624
- if ( ! shallow && child !== null ) {
640
+
641
+ if ( child !== null ) {
625
642
current_effect = child ;
626
643
continue ;
627
644
}
628
645
} else if ( ( flags & EFFECT ) !== 0 ) {
629
646
if ( is_branch || is_clean ) {
630
- if ( ! shallow && child !== null ) {
647
+ if ( child !== null ) {
631
648
current_effect = child ;
632
649
continue ;
633
650
}
@@ -657,62 +674,15 @@ function process_effects(effect, filter_flags, shallow, collected_effects) {
657
674
current_effect = sibling ;
658
675
}
659
676
660
- if ( effects . length > 0 ) {
661
- // We might be dealing with many effects here, far more than can be spread into
662
- // an array push call (callstack overflow). So let's deal with each effect in a loop.
663
- for ( var i = 0 ; i < effects . length ; i ++ ) {
664
- if ( ( filter_flags & EFFECT ) !== 0 ) {
665
- collected_effects . push ( effects [ i ] ) ;
666
- }
667
- if ( ! shallow ) {
668
- process_effects ( effects [ i ] , filter_flags , false , collected_effects ) ;
669
- }
670
- }
677
+ // We might be dealing with many effects here, far more than can be spread into
678
+ // an array push call (callstack overflow). So let's deal with each effect in a loop.
679
+ for ( var i = 0 ; i < effects . length ; i ++ ) {
680
+ child = effects [ i ] ;
681
+ collected_effects . push ( child ) ;
682
+ process_effects ( child , collected_effects ) ;
671
683
}
672
684
}
673
685
674
- /**
675
- *
676
- * This function recursively collects effects in topological order from the starting effect passed in.
677
- * Effects will be collected when they match the filtered bitwise flag passed in only. The collected
678
- * array will be populated with all the effects.
679
- *
680
- * @param {import('#client').Effect } effect
681
- * @param {number } filter_flags
682
- * @param {boolean } [shallow]
683
- * @returns {void }
684
- */
685
- function flush_nested_effects ( effect , filter_flags , shallow = false ) {
686
- /** @type {import('#client').Effect[] } */
687
- var collected_effects = [ ] ;
688
-
689
- var previously_flushing_effect = is_flushing_effect ;
690
- is_flushing_effect = true ;
691
-
692
- try {
693
- // When working with custom elements, the root effects might not have a root
694
- if ( effect . first === null && ( effect . f & BRANCH_EFFECT ) === 0 ) {
695
- flush_queued_effects ( [ effect ] ) ;
696
- } else {
697
- process_effects ( effect , filter_flags , shallow , collected_effects ) ;
698
- flush_queued_effects ( collected_effects ) ;
699
- }
700
- } finally {
701
- is_flushing_effect = previously_flushing_effect ;
702
- }
703
- }
704
-
705
- /**
706
- * @param {import('#client').Effect } effect
707
- * @returns {void }
708
- */
709
- export function flush_local_render_effects ( effect ) {
710
- infinite_loop_guard ( ) ;
711
- // We are entering a new flush sequence, so ensure counter is reset.
712
- flush_count = 0 ;
713
- flush_nested_effects ( effect , RENDER_EFFECT , true ) ;
714
- }
715
-
716
686
/**
717
687
* Internal version of `flushSync` with the option to not flush previous effects.
718
688
* Returns the result of the passed function, if given.
0 commit comments