feat(runtime-core): set context for manual slot functions as well
This commit is contained in:
@@ -24,13 +24,12 @@ export function popScopeId() {
|
||||
export function withScopeId(id: string): <T extends Function>(fn: T) => T {
|
||||
if (__BUNDLER__) {
|
||||
return ((fn: Function, ctx?: ComponentInternalInstance) => {
|
||||
function renderWithId(this: any) {
|
||||
return withCtx(function(this: any) {
|
||||
pushScopeId(id)
|
||||
const res = fn.apply(this, arguments)
|
||||
popScopeId()
|
||||
return res
|
||||
}
|
||||
return ctx ? withCtx(renderWithId, ctx) : renderWithId
|
||||
}, ctx)
|
||||
}) as any
|
||||
} else {
|
||||
return undefined as any
|
||||
|
||||
@@ -5,7 +5,11 @@ import {
|
||||
currentRenderingInstance
|
||||
} from '../componentRenderUtils'
|
||||
|
||||
export function withCtx(fn: Slot, ctx: ComponentInternalInstance) {
|
||||
export function withCtx(
|
||||
fn: Slot,
|
||||
ctx: ComponentInternalInstance | null | undefined
|
||||
) {
|
||||
if (!ctx) return fn
|
||||
return function renderFnWithContext() {
|
||||
const owner = currentRenderingInstance
|
||||
setCurrentRenderingInstance(ctx)
|
||||
|
||||
Reference in New Issue
Block a user