|
|
@@ -10,9 +10,10 @@ import { warn, resolveAsset } from '../util/index'
|
|
|
export function renderElementWithChildren (
|
|
|
vnode: VNode | void,
|
|
|
children: VNodeChildren | void
|
|
|
-): VNode | void {
|
|
|
+): VNode | Array<VNode> | void {
|
|
|
if (vnode) {
|
|
|
- if (vnode.componentOptions) {
|
|
|
+ const componentOptions = vnode.componentOptions
|
|
|
+ if (componentOptions) {
|
|
|
if (process.env.NODE_ENV !== 'production' &&
|
|
|
children && typeof children !== 'function') {
|
|
|
warn(
|
|
|
@@ -21,8 +22,21 @@ export function renderElementWithChildren (
|
|
|
'dependencies and optimizes re-rendering.'
|
|
|
)
|
|
|
}
|
|
|
- vnode.componentOptions.children = children
|
|
|
+ const CtorOptions = componentOptions.Ctor.options
|
|
|
+ // functional component
|
|
|
+ if (CtorOptions.functional) {
|
|
|
+ return CtorOptions.render.call(
|
|
|
+ null,
|
|
|
+ componentOptions.parent.$createElement, // h
|
|
|
+ componentOptions.propsData || {}, // props
|
|
|
+ normalizeChildren(children) // children
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ // normal component
|
|
|
+ componentOptions.children = children
|
|
|
+ }
|
|
|
} else {
|
|
|
+ // normal element
|
|
|
vnode.setChildren(normalizeChildren(children))
|
|
|
}
|
|
|
}
|