Skip to content

Commit 2089f54

Browse files
committed
chore: improve code
chore: improve code chore: improve code chore(deps): update dependency @types/node to v18 (vuejs#9323) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> chore: improve code
1 parent 0c76a4f commit 2089f54

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
"@rollup/plugin-replace": "^5.0.2",
6767
"@rollup/plugin-terser": "^0.4.3",
6868
"@types/hash-sum": "^1.0.0",
69-
"@types/node": "^16.18.52",
69+
"@types/node": "^18.18.5",
7070
"@typescript-eslint/parser": "^6.7.2",
7171
"@vitest/coverage-istanbul": "^0.34.4",
7272
"@vue/consolidate": "0.17.3",

packages/runtime-core/src/components/Suspense.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ export interface SuspenseBoundary {
379379
container: RendererElement
380380
hiddenContainer: RendererElement
381381
anchor: RendererNode | null
382-
activeBranch: (VNode & { __isUnmounted?: boolean }) | null
382+
activeBranch: VNode | null
383+
preActiveBranch: VNode | null
383384
pendingBranch: VNode | null
384385
deps: number
385386
pendingId: number
@@ -462,6 +463,7 @@ function createSuspenseBoundary(
462463
pendingId: 0,
463464
timeout: typeof timeout === 'number' ? timeout : -1,
464465
activeBranch: null,
466+
preActiveBranch: null,
465467
pendingBranch: null,
466468
isInFallback: true,
467469
isHydrating,
@@ -506,12 +508,12 @@ function createSuspenseBoundary(
506508
}
507509
}
508510
// this is initial anchor on mount
509-
let { anchor } = suspense
511+
let { anchor, preActiveBranch } = suspense
510512
// unmount current active tree
511513
// #7966 if suspense is wrapped in Transition, the Transition's afterLeave may not have been
512514
// performed (this means the fallbackVNode not mounted) when suspense resolves.
513515
// so avoid unmount activeBranch again
514-
if (activeBranch && !activeBranch.__isUnmounted) {
516+
if (activeBranch && activeBranch !== preActiveBranch) {
515517
// if the fallback tree was mounted, it may have been moved
516518
// as part of a parent suspense. get the latest anchor for insertion
517519
anchor = next(activeBranch)
@@ -594,6 +596,7 @@ function createSuspenseBoundary(
594596
optimized
595597
)
596598
setActiveBranch(suspense, fallbackVNode)
599+
suspense.preActiveBranch = null
597600
}
598601

599602
const delayEnter =
@@ -611,7 +614,7 @@ function createSuspenseBoundary(
611614
true // shouldRemove
612615
)
613616

614-
activeBranch!.__isUnmounted = true
617+
suspense.preActiveBranch = activeBranch!
615618

616619
if (!delayEnter) {
617620
mountFallback()
@@ -691,6 +694,7 @@ function createSuspenseBoundary(
691694

692695
unmount(parentSuspense, doRemove) {
693696
suspense.isUnmounted = true
697+
suspense.preActiveBranch = null
694698
if (suspense.activeBranch) {
695699
unmount(
696700
suspense.activeBranch,

pnpm-lock.yaml

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)