From: Yi Yang Date: Thu, 30 May 2024 02:51:30 +0000 (+0800) Subject: fix(teleport): do not throw target warning when teleport is disabled (#9818) X-Git-Tag: v3.4.28~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15ee43f66ad2485ac212b02b444345d867b3c060;p=thirdparty%2Fvuejs%2Fcore.git fix(teleport): do not throw target warning when teleport is disabled (#9818) --- diff --git a/packages/runtime-core/src/components/Teleport.ts b/packages/runtime-core/src/components/Teleport.ts index 0de0ebf787..8d174e2022 100644 --- a/packages/runtime-core/src/components/Teleport.ts +++ b/packages/runtime-core/src/components/Teleport.ts @@ -47,14 +47,13 @@ const resolveTarget = ( return null } else { const target = select(targetSelector) - if (!target) { - __DEV__ && - warn( - `Failed to locate Teleport target with selector "${targetSelector}". ` + - `Note the target element must exist before the component is mounted - ` + - `i.e. the target cannot be rendered by the component itself, and ` + - `ideally should be outside of the entire Vue component tree.`, - ) + if (__DEV__ && !target && !isTeleportDisabled(props)) { + warn( + `Failed to locate Teleport target with selector "${targetSelector}". ` + + `Note the target element must exist before the component is mounted - ` + + `i.e. the target cannot be rendered by the component itself, and ` + + `ideally should be outside of the entire Vue component tree.`, + ) } return target as T }