mirror of https://github.com/vuejs/core.git
chore: fix vdom slots currentInstance
This commit is contained in:
parent
e8067f1cd9
commit
6c4018652b
|
@ -1,4 +1,4 @@
|
||||||
import { type ComponentInternalInstance, getCurrentInstance } from './component'
|
import { type ComponentInternalInstance, currentInstance } from './component'
|
||||||
import {
|
import {
|
||||||
type VNode,
|
type VNode,
|
||||||
type VNodeChild,
|
type VNodeChild,
|
||||||
|
@ -94,15 +94,17 @@ const normalizeSlot = (
|
||||||
return rawSlot as Slot
|
return rawSlot as Slot
|
||||||
}
|
}
|
||||||
const normalized = withCtx((...args: any[]) => {
|
const normalized = withCtx((...args: any[]) => {
|
||||||
if (__DEV__) {
|
if (
|
||||||
const currentInstance = getCurrentInstance()
|
__DEV__ &&
|
||||||
if (currentInstance && (!ctx || ctx.root === currentInstance.root)) {
|
currentInstance &&
|
||||||
warn(
|
!currentInstance.vapor &&
|
||||||
`Slot "${key}" invoked outside of the render function: ` +
|
(!ctx || ctx.root === (currentInstance as ComponentInternalInstance).root)
|
||||||
`this will not track dependencies used in the slot. ` +
|
) {
|
||||||
`Invoke the slot function inside the render function instead.`,
|
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))
|
return normalizeSlotValue(rawSlot(...args))
|
||||||
}, ctx) as Slot
|
}, ctx) as Slot
|
||||||
|
|
Loading…
Reference in New Issue