]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: fix vdom slots currentInstance
authorEvan You <evan@vuejs.org>
Sun, 8 Dec 2024 08:41:53 +0000 (16:41 +0800)
committerEvan You <evan@vuejs.org>
Sun, 8 Dec 2024 08:42:07 +0000 (16:42 +0800)
packages/runtime-core/src/componentSlots.ts

index 34aaa39df613c46cdcb759aa50a57736e2ccc031..66b7a0f9dfba4f7118b6cebf87ebcd1274e766b4 100644 (file)
@@ -1,4 +1,4 @@
-import { type ComponentInternalInstance, getCurrentInstance } from './component'
+import { type ComponentInternalInstance, currentInstance } from './component'
 import {
   type VNode,
   type VNodeChild,
@@ -94,15 +94,17 @@ const normalizeSlot = (
     return rawSlot as Slot
   }
   const normalized = withCtx((...args: any[]) => {
-    if (__DEV__) {
-      const currentInstance = getCurrentInstance()
-      if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
-        warn(
-          `Slot "${key}" invoked outside of the render function: ` +
-            `this will not track dependencies used in the slot. ` +
-            `Invoke the slot function inside the render function instead.`,
-        )
-      }
+    if (
+      __DEV__ &&
+      currentInstance &&
+      !currentInstance.vapor &&
+      (!ctx || ctx.root === (currentInstance as ComponentInternalInstance).root)
+    ) {
+      warn(
+        `Slot "${key}" invoked outside of the render function: ` +
+          `this will not track dependencies used in the slot. ` +
+          `Invoke the slot function inside the render function instead.`,
+      )
     }
     return normalizeSlotValue(rawSlot(...args))
   }, ctx) as Slot