]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(teleport): do not throw target warning when teleport is disabled (#9818)
authorYi Yang <Leopoldthecoder@users.noreply.github.com>
Thu, 30 May 2024 02:51:30 +0000 (10:51 +0800)
committerGitHub <noreply@github.com>
Thu, 30 May 2024 02:51:30 +0000 (10:51 +0800)
packages/runtime-core/src/components/Teleport.ts

index 0de0ebf787edfeedd033096c3158c32a51aec687..8d174e2022cb3931ab6576a310a17f89aca054b1 100644 (file)
@@ -47,14 +47,13 @@ const resolveTarget = <T = RendererElement>(
       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
     }