feat(runtime-core): set context for manual slot functions as well

This commit is contained in:
Evan You
2020-03-16 12:20:52 -04:00
parent ecd7ce60d5
commit 8a58dce603
5 changed files with 37 additions and 19 deletions

View File

@@ -30,6 +30,7 @@ import { TransitionHooks } from './components/BaseTransition'
import { warn } from './warning'
import { currentScopeId } from './helpers/scopeId'
import { PortalImpl, isPortal } from './components/Portal'
import { currentRenderingInstance } from './componentRenderUtils'
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
__isFragment: true
@@ -387,8 +388,11 @@ export function normalizeChildren(vnode: VNode, children: unknown) {
type = ShapeFlags.ARRAY_CHILDREN
} else if (typeof children === 'object') {
type = ShapeFlags.SLOTS_CHILDREN
if (!(children as RawSlots)._) {
;(children as RawSlots)._ctx = currentRenderingInstance
}
} else if (isFunction(children)) {
children = { default: children }
children = { default: children, _ctx: currentRenderingInstance }
type = ShapeFlags.SLOTS_CHILDREN
} else {
children = String(children)