From b67841172dc6eb6b13b2d2cdefb1dc55c8d5e094 Mon Sep 17 00:00:00 2001 From: daiwei Date: Tue, 14 Jan 2025 09:14:41 +0800 Subject: [PATCH] fix(Teleport): handle teleport unmount edge case --- packages/runtime-core/src/components/Teleport.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/src/components/Teleport.ts b/packages/runtime-core/src/components/Teleport.ts index fe6fa36c1c..b402df37b3 100644 --- a/packages/runtime-core/src/components/Teleport.ts +++ b/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( -- 2.47.2