@@ -379,7 +379,8 @@ export interface SuspenseBoundary {
379
379
container : RendererElement
380
380
hiddenContainer : RendererElement
381
381
anchor : RendererNode | null
382
- activeBranch : ( VNode & { __isUnmounted ?: boolean } ) | null
382
+ activeBranch : VNode | null
383
+ initialContent : VNode | null
383
384
pendingBranch : VNode | null
384
385
deps : number
385
386
pendingId : number
@@ -462,6 +463,7 @@ function createSuspenseBoundary(
462
463
pendingId : 0 ,
463
464
timeout : typeof timeout === 'number' ? timeout : - 1 ,
464
465
activeBranch : null ,
466
+ initialContent : null ,
465
467
pendingBranch : null ,
466
468
isInFallback : true ,
467
469
isHydrating,
@@ -506,12 +508,13 @@ function createSuspenseBoundary(
506
508
}
507
509
}
508
510
// this is initial anchor on mount
509
- let { anchor } = suspense
511
+ let { anchor, initialContent } = suspense
510
512
// unmount current active tree
511
- // #7966 if suspense is wrapped in Transition, the Transition's afterLeave may not have been
512
- // performed (this means the fallbackVNode not mounted) when suspense resolves.
513
- // so avoid unmount activeBranch again
514
- if ( activeBranch && ! activeBranch . __isUnmounted ) {
513
+ // #7966 when Suspense is wrapped in Transition, the fallback node will be mounted
514
+ // in the afterLeave of Transition. This means that when Suspense is resolved,
515
+ // the activeBranch is not the fallback node but the initialContent.
516
+ // so avoid unmounting the activateBranch again.
517
+ if ( activeBranch && activeBranch !== initialContent ) {
515
518
// if the fallback tree was mounted, it may have been moved
516
519
// as part of a parent suspense. get the latest anchor for insertion
517
520
anchor = next ( activeBranch )
@@ -578,6 +581,7 @@ function createSuspenseBoundary(
578
581
579
582
const anchor = next ( activeBranch ! )
580
583
const mountFallback = ( ) => {
584
+ suspense . initialContent = null
581
585
if ( ! suspense . isInFallback ) {
582
586
return
583
587
}
@@ -599,6 +603,7 @@ function createSuspenseBoundary(
599
603
const delayEnter =
600
604
fallbackVNode . transition && fallbackVNode . transition . mode === 'out-in'
601
605
if ( delayEnter ) {
606
+ suspense . initialContent = activeBranch !
602
607
activeBranch ! . transition ! . afterLeave = mountFallback
603
608
}
604
609
suspense . isInFallback = true
@@ -611,8 +616,6 @@ function createSuspenseBoundary(
611
616
true // shouldRemove
612
617
)
613
618
614
- activeBranch ! . __isUnmounted = true
615
-
616
619
if ( ! delayEnter ) {
617
620
mountFallback ( )
618
621
}
0 commit comments