@@ -408,6 +408,7 @@ export interface SuspenseBoundary {
408
408
isInFallback : boolean
409
409
isHydrating : boolean
410
410
isUnmounted : boolean
411
+ preEffects : Function [ ]
411
412
effects : Function [ ]
412
413
resolve ( force ?: boolean , sync ?: boolean ) : void
413
414
fallback ( fallbackVNode : VNode ) : void
@@ -488,6 +489,7 @@ function createSuspenseBoundary(
488
489
isInFallback : ! isHydrating ,
489
490
isHydrating,
490
491
isUnmounted : false ,
492
+ preEffects : [ ] ,
491
493
effects : [ ] ,
492
494
493
495
resolve ( resume = false , sync = false ) {
@@ -508,6 +510,7 @@ function createSuspenseBoundary(
508
510
activeBranch,
509
511
pendingBranch,
510
512
pendingId,
513
+ preEffects,
511
514
effects,
512
515
parentComponent,
513
516
container,
@@ -518,6 +521,10 @@ function createSuspenseBoundary(
518
521
if ( suspense . isHydrating ) {
519
522
suspense . isHydrating = false
520
523
} else if ( ! resume ) {
524
+ if ( preEffects ) {
525
+ preEffects . forEach ( e => e ( ) )
526
+ preEffects . length = 0
527
+ }
521
528
delayEnter =
522
529
activeBranch &&
523
530
pendingBranch ! . transition &&
@@ -723,25 +730,29 @@ function createSuspenseBoundary(
723
730
} ,
724
731
725
732
unmount ( parentSuspense , doRemove ) {
726
- if ( parentSuspense && parentSuspense . deps > 0 ) {
727
- return
728
- }
729
- suspense . isUnmounted = true
730
- if ( suspense . activeBranch ) {
731
- unmount (
732
- suspense . activeBranch ,
733
- parentComponent ,
734
- parentSuspense ,
735
- doRemove ,
736
- )
733
+ const performUnmount = ( ) => {
734
+ suspense . isUnmounted = true
735
+ if ( suspense . activeBranch ) {
736
+ unmount (
737
+ suspense . activeBranch ,
738
+ parentComponent ,
739
+ parentSuspense ,
740
+ doRemove ,
741
+ )
742
+ }
743
+ if ( suspense . pendingBranch ) {
744
+ unmount (
745
+ suspense . pendingBranch ,
746
+ parentComponent ,
747
+ parentSuspense ,
748
+ doRemove ,
749
+ )
750
+ }
737
751
}
738
- if ( suspense . pendingBranch ) {
739
- unmount (
740
- suspense . pendingBranch ,
741
- parentComponent ,
742
- parentSuspense ,
743
- doRemove ,
744
- )
752
+ if ( parentSuspense && parentSuspense . deps > 0 ) {
753
+ parentSuspense . preEffects . push ( performUnmount )
754
+ } else {
755
+ performUnmount ( )
745
756
}
746
757
} ,
747
758
}
0 commit comments