Skip to content

Commit

Permalink
fix(teleport): should only force remove teleport when not disabled
Browse files Browse the repository at this point in the history
fix #2323
  • Loading branch information
yyx990803 committed Oct 9, 2020
1 parent 54ed759 commit b0931dc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/runtime-core/src/components/Teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
13 changes: 10 additions & 3 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit b0931dc

Please sign in to comment.