2
0
Эх сурвалжийг харах

fix(Teleport): handle teleport unmount edge case

daiwei 1 жил өмнө
parent
commit
b67841172d

+ 6 - 1
packages/runtime-core/src/components/Teleport.ts

@@ -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(