]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(teleport): should only force remove teleport when not disabled
authorEvan You <yyx990803@gmail.com>
Fri, 9 Oct 2020 13:08:59 +0000 (09:08 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 9 Oct 2020 13:08:59 +0000 (09:08 -0400)
fix #2323

packages/runtime-core/src/components/Teleport.ts
packages/runtime-core/src/renderer.ts

index dae83eea6178e092c84be02a430d2778ca6b0567..1b43061642c117523fb85e5aaae8958916dce3aa 100644 (file)
@@ -20,7 +20,7 @@ export interface TeleportProps {
 
 export const isTeleport = (type: any): boolean => type.__isTeleport
 
-const isTeleportDisabled = (props: VNode['props']): boolean =>
+export const isTeleportDisabled = (props: VNode['props']): boolean =>
   props && (props.disabled || props.disabled === '')
 
 const resolveTarget = <T = RendererElement>(
index 3baea539a87bfcf6401f44cd38227a430b397119..4cd7ccc27c0951208a869a1466d7a0d68196b178 100644 (file)
@@ -56,7 +56,11 @@ import {
   queueEffectWithSuspense,
   SuspenseImpl
 } from './components/Suspense'
-import { TeleportImpl, TeleportVNode } from './components/Teleport'
+import {
+  isTeleportDisabled,
+  TeleportImpl,
+  TeleportVNode
+} from './components/Teleport'
 import { isKeepAlive, KeepAliveContext } from './components/KeepAlive'
 import { registerHMR, unregisterHMR, isHmrUpdating } from './hmr'
 import {
@@ -2037,8 +2041,11 @@ function baseCreateRenderer(
         unmountChildren(children as VNode[], parentComponent, parentSuspense)
       }
 
-      // an unmounted teleport should always remove its children
-      if (shapeFlag & ShapeFlags.TELEPORT) {
+      // an unmounted teleport should always remove its children if not disabled
+      if (
+        shapeFlag & ShapeFlags.TELEPORT &&
+        (doRemove || !isTeleportDisabled(vnode.props))
+      ) {
         ;(vnode.type as typeof TeleportImpl).remove(vnode, internals)
       }