]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(suspense): clear placeholder and fallback el after resolve to enable GC (#13928)
authoredison <daiwei521@126.com>
Wed, 5 Nov 2025 13:53:06 +0000 (21:53 +0800)
committerGitHub <noreply@github.com>
Wed, 5 Nov 2025 13:53:06 +0000 (21:53 +0800)
packages/runtime-core/src/components/Suspense.ts

index 0109d77c3f214efc00002bbf8d1a0f4d1d7b5bd6..d14e96be3d0b64558f12fa90fe51bb993bbea644 100644 (file)
@@ -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
@@ -728,6 +738,8 @@ function createSuspenseBoundary(
             optimized,
           )
           if (placeholder) {
+            // clean up placeholder reference
+            vnode.placeholder = null
             remove(placeholder)
           }
           updateHOCHostEl(instance, vnode.el)