From: daiwei Date: Tue, 14 Jan 2025 01:14:41 +0000 (+0800) Subject: fix(Teleport): handle teleport unmount edge case X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b67841172dc6eb6b13b2d2cdefb1dc55c8d5e094;p=thirdparty%2Fvuejs%2Fcore.git fix(Teleport): handle teleport unmount edge case --- 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(