From 9954f4546e0563c17fadf91fb9cfdf525bd7ff74 Mon Sep 17 00:00:00 2001 From: daiwei Date: Wed, 5 Nov 2025 20:46:53 +0800 Subject: [PATCH] fix(Suspense): clear el reference from fallback vnode to allow garbage collection --- packages/runtime-core/src/components/Suspense.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/runtime-core/src/components/Suspense.ts b/packages/runtime-core/src/components/Suspense.ts index 368d834f19..d14e96be3d 100644 --- a/packages/runtime-core/src/components/Suspense.ts +++ b/packages/runtime-core/src/components/Suspense.ts @@ -530,6 +530,7 @@ function createSuspenseBoundary( effects, parentComponent, container, + isInFallback, } = suspense // if there's a transition happening we need to wait it to finish. @@ -551,6 +552,10 @@ function createSuspenseBoundary( MoveType.ENTER, ) queuePostFlushCb(effects) + // clear el reference from fallback vnode to allow GC after transition + if (isInFallback && vnode.ssFallback) { + vnode.ssFallback.el = null + } } } } @@ -570,6 +575,11 @@ function createSuspenseBoundary( anchor = next(activeBranch) } unmount(activeBranch, parentComponent, suspense, true) + // clear el reference from fallback vnode to allow GC + // only clear immediately if there's no delayed transition + if (!delayEnter && isInFallback && vnode.ssFallback) { + vnode.ssFallback.el = null + } } if (!delayEnter) { // move content from off-dom container to actual container -- 2.47.3