@@ -420,6 +420,7 @@ export interface SuspenseBoundary {
420
420
isInFallback : boolean
421
421
isHydrating : boolean
422
422
isUnmounted : boolean
423
+ preEffects : Function [ ]
423
424
effects : Function [ ]
424
425
resolve ( force ?: boolean , sync ?: boolean ) : void
425
426
fallback ( fallbackVNode : VNode ) : void
@@ -500,6 +501,7 @@ function createSuspenseBoundary(
500
501
isInFallback : ! isHydrating ,
501
502
isHydrating,
502
503
isUnmounted : false ,
504
+ preEffects : [ ] ,
503
505
effects : [ ] ,
504
506
505
507
resolve ( resume = false , sync = false ) {
@@ -520,6 +522,7 @@ function createSuspenseBoundary(
520
522
activeBranch,
521
523
pendingBranch,
522
524
pendingId,
525
+ preEffects,
523
526
effects,
524
527
parentComponent,
525
528
container,
@@ -530,6 +533,10 @@ function createSuspenseBoundary(
530
533
if ( suspense . isHydrating ) {
531
534
suspense . isHydrating = false
532
535
} else if ( ! resume ) {
536
+ if ( preEffects ) {
537
+ preEffects . forEach ( e => e ( ) )
538
+ preEffects . length = 0
539
+ }
533
540
delayEnter =
534
541
activeBranch &&
535
542
pendingBranch ! . transition &&
@@ -735,25 +742,29 @@ function createSuspenseBoundary(
735
742
} ,
736
743
737
744
unmount ( parentSuspense , doRemove ) {
738
- if ( parentSuspense && parentSuspense . deps > 0 ) {
739
- return
740
- }
741
- suspense . isUnmounted = true
742
- if ( suspense . activeBranch ) {
743
- unmount (
744
- suspense . activeBranch ,
745
- parentComponent ,
746
- parentSuspense ,
747
- doRemove ,
748
- )
745
+ const performUnmount = ( ) => {
746
+ suspense . isUnmounted = true
747
+ if ( suspense . activeBranch ) {
748
+ unmount (
749
+ suspense . activeBranch ,
750
+ parentComponent ,
751
+ parentSuspense ,
752
+ doRemove ,
753
+ )
754
+ }
755
+ if ( suspense . pendingBranch ) {
756
+ unmount (
757
+ suspense . pendingBranch ,
758
+ parentComponent ,
759
+ parentSuspense ,
760
+ doRemove ,
761
+ )
762
+ }
749
763
}
750
- if ( suspense . pendingBranch ) {
751
- unmount (
752
- suspense . pendingBranch ,
753
- parentComponent ,
754
- parentSuspense ,
755
- doRemove ,
756
- )
764
+ if ( parentSuspense && parentSuspense . deps > 0 ) {
765
+ parentSuspense . preEffects . push ( performUnmount )
766
+ } else {
767
+ performUnmount ( )
757
768
}
758
769
} ,
759
770
}
0 commit comments