From: Evan You Date: Sun, 8 Dec 2024 08:41:53 +0000 (+0800) Subject: chore: fix vdom slots currentInstance X-Git-Tag: v3.6.0-alpha.1~16^2~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c4018652b4bbdf0b1e15b56cd1ea854b7d775c3;p=thirdparty%2Fvuejs%2Fcore.git chore: fix vdom slots currentInstance --- diff --git a/packages/runtime-core/src/componentSlots.ts b/packages/runtime-core/src/componentSlots.ts index 34aaa39df6..66b7a0f9df 100644 --- a/packages/runtime-core/src/componentSlots.ts +++ b/packages/runtime-core/src/componentSlots.ts @@ -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