chore: fix vdom slots currentInstance

This commit is contained in:
Evan You 2024-12-08 16:41:53 +08:00
parent e8067f1cd9
commit 6c4018652b
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
1 changed files with 12 additions and 10 deletions

View File

@ -1,4 +1,4 @@
import { type ComponentInternalInstance, getCurrentInstance } from './component'
import { type ComponentInternalInstance, currentInstance } from './component'
import {
type VNode,
type VNodeChild,
@ -94,16 +94,18 @@ const normalizeSlot = (
return rawSlot as Slot
}
const normalized = withCtx((...args: any[]) => {
if (__DEV__) {
const currentInstance = getCurrentInstance()
if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
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
// NOT a compiled slot