]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(Teleport): handle teleport unmount edge case
authordaiwei <daiwei521@126.com>
Tue, 14 Jan 2025 01:14:41 +0000 (09:14 +0800)
committerdaiwei <daiwei521@126.com>
Tue, 14 Jan 2025 01:14:41 +0000 (09:14 +0800)
packages/runtime-core/src/components/Teleport.ts

index fe6fa36c1ca4a5730589b10ba8bcf359238c1742..b402df37b3408649c43e63dd5d496777a6d37e53 100644 (file)
@@ -316,8 +316,13 @@ export const TeleportImpl = {
 
     // an unmounted teleport should always unmount its children whether it's disabled or not
     doRemove && hostRemove(anchor!)
+
+    // skip unmount if not disabled & target missing (children not rendered)
+    const disabled = isTeleportDisabled(props)
+    if (!disabled && !target) return
+
     if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
-      const shouldRemove = doRemove || !isTeleportDisabled(props)
+      const shouldRemove = doRemove || !disabled
       for (let i = 0; i < (children as VNode[]).length; i++) {
         const child = (children as VNode[])[i]
         unmount(