Skip to content

Commit b0931dc

Browse files
committed
fix(teleport): should only force remove teleport when not disabled
fix #2323
1 parent 54ed759 commit b0931dc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface TeleportProps {
2020

2121
export const isTeleport = (type: any): boolean => type.__isTeleport
2222

23-
const isTeleportDisabled = (props: VNode['props']): boolean =>
23+
export const isTeleportDisabled = (props: VNode['props']): boolean =>
2424
props && (props.disabled || props.disabled === '')
2525

2626
const resolveTarget = <T = RendererElement>(

packages/runtime-core/src/renderer.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ import {
5656
queueEffectWithSuspense,
5757
SuspenseImpl
5858
} from './components/Suspense'
59-
import { TeleportImpl, TeleportVNode } from './components/Teleport'
59+
import {
60+
isTeleportDisabled,
61+
TeleportImpl,
62+
TeleportVNode
63+
} from './components/Teleport'
6064
import { isKeepAlive, KeepAliveContext } from './components/KeepAlive'
6165
import { registerHMR, unregisterHMR, isHmrUpdating } from './hmr'
6266
import {
@@ -2037,8 +2041,11 @@ function baseCreateRenderer(
20372041
unmountChildren(children as VNode[], parentComponent, parentSuspense)
20382042
}
20392043

2040-
// an unmounted teleport should always remove its children
2041-
if (shapeFlag & ShapeFlags.TELEPORT) {
2044+
// an unmounted teleport should always remove its children if not disabled
2045+
if (
2046+
shapeFlag & ShapeFlags.TELEPORT &&
2047+
(doRemove || !isTeleportDisabled(vnode.props))
2048+
) {
20422049
;(vnode.type as typeof TeleportImpl).remove(vnode, internals)
20432050
}
20442051

0 commit comments

Comments
 (0)