@@ -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
+ preActiveBranch : 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
+ preActiveBranch : null ,
465
467
pendingBranch : null ,
466
468
isInFallback : true ,
467
469
isHydrating,
@@ -506,12 +508,12 @@ function createSuspenseBoundary(
506
508
}
507
509
}
508
510
// this is initial anchor on mount
509
- let { anchor } = suspense
511
+ let { anchor, preActiveBranch } = suspense
510
512
// unmount current active tree
511
513
// #7966 if suspense is wrapped in Transition, the Transition's afterLeave may not have been
512
514
// performed (this means the fallbackVNode not mounted) when suspense resolves.
513
515
// so avoid unmount activeBranch again
514
- if ( activeBranch && ! activeBranch . __isUnmounted ) {
516
+ if ( activeBranch && activeBranch !== preActiveBranch ) {
515
517
// if the fallback tree was mounted, it may have been moved
516
518
// as part of a parent suspense. get the latest anchor for insertion
517
519
anchor = next ( activeBranch )
@@ -594,6 +596,7 @@ function createSuspenseBoundary(
594
596
optimized
595
597
)
596
598
setActiveBranch ( suspense , fallbackVNode )
599
+ suspense . preActiveBranch = null
597
600
}
598
601
599
602
const delayEnter =
@@ -611,7 +614,7 @@ function createSuspenseBoundary(
611
614
true // shouldRemove
612
615
)
613
616
614
- activeBranch ! . __isUnmounted = true
617
+ suspense . preActiveBranch = activeBranch !
615
618
616
619
if ( ! delayEnter ) {
617
620
mountFallback ( )
@@ -691,6 +694,7 @@ function createSuspenseBoundary(
691
694
692
695
unmount ( parentSuspense , doRemove ) {
693
696
suspense . isUnmounted = true
697
+ suspense . preActiveBranch = null
694
698
if ( suspense . activeBranch ) {
695
699
unmount (
696
700
suspense . activeBranch ,
0 commit comments