Selaa lähdekoodia

fix(Teleport): handle teleport unmount edge case

daiwei 1 vuosi sitten
vanhempi
commit
b67841172d
1 muutettua tiedostoa jossa 6 lisäystä ja 1 poistoa
  1. 6 1
      packages/runtime-core/src/components/Teleport.ts

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