Skip to content

Commit f411c66

Browse files
authored
fix(suspense): clear placeholder and fallback el after resolve to enable GC (#13928)
1 parent dc4dd59 commit f411c66

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ function createSuspenseBoundary(
530530
effects,
531531
parentComponent,
532532
container,
533+
isInFallback,
533534
} = suspense
534535

535536
// if there's a transition happening we need to wait it to finish.
@@ -551,6 +552,10 @@ function createSuspenseBoundary(
551552
MoveType.ENTER,
552553
)
553554
queuePostFlushCb(effects)
555+
// clear el reference from fallback vnode to allow GC after transition
556+
if (isInFallback && vnode.ssFallback) {
557+
vnode.ssFallback.el = null
558+
}
554559
}
555560
}
556561
}
@@ -570,6 +575,11 @@ function createSuspenseBoundary(
570575
anchor = next(activeBranch)
571576
}
572577
unmount(activeBranch, parentComponent, suspense, true)
578+
// clear el reference from fallback vnode to allow GC
579+
// only clear immediately if there's no delayed transition
580+
if (!delayEnter && isInFallback && vnode.ssFallback) {
581+
vnode.ssFallback.el = null
582+
}
573583
}
574584
if (!delayEnter) {
575585
// move content from off-dom container to actual container
@@ -728,6 +738,8 @@ function createSuspenseBoundary(
728738
optimized,
729739
)
730740
if (placeholder) {
741+
// clean up placeholder reference
742+
vnode.placeholder = null
731743
remove(placeholder)
732744
}
733745
updateHOCHostEl(instance, vnode.el)

0 commit comments

Comments
 (0)