daiwei преди 1 година
родител
ревизия
6daa180de9
променени са 1 файла, в които са добавени 5 реда и са изтрити 6 реда
  1. 5 6
      packages/runtime-core/src/components/Teleport.ts

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

@@ -308,12 +308,6 @@ export const TeleportImpl = {
       target,
       target,
       props,
       props,
     } = vnode
     } = vnode
-
-    if (target) {
-      hostRemove(targetStart!)
-      hostRemove(targetAnchor!)
-    }
-
     // an unmounted teleport should always unmount its children whether it's disabled or not
     // an unmounted teleport should always unmount its children whether it's disabled or not
     doRemove && hostRemove(anchor!)
     doRemove && hostRemove(anchor!)
 
 
@@ -321,6 +315,11 @@ export const TeleportImpl = {
     const disabled = isTeleportDisabled(props)
     const disabled = isTeleportDisabled(props)
     if (!disabled && !target) return
     if (!disabled && !target) return
 
 
+    if (target) {
+      hostRemove(targetStart!)
+      hostRemove(targetAnchor!)
+    }
+
     if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
     if (shapeFlag & ShapeFlags.ARRAY_CHILDREN) {
       const shouldRemove = doRemove || !disabled
       const shouldRemove = doRemove || !disabled
       for (let i = 0; i < (children as VNode[]).length; i++) {
       for (let i = 0; i < (children as VNode[]).length; i++) {