export interface FunctionalComponent<P = Data> extends RenderFunction<P> {
pure?: boolean
props?: ComponentPropsOptions<P>
+ inheritAttrs?: boolean
}
// this interface is merged with the class type
computed?: ComponentComputedOptions<D, P>
watch?: ComponentWatchOptions<D, P>
render?: RenderFunction<P>
+ inheritAttrs?: boolean
// TODO other options
readonly [key: string]: any
}
}
}
}
- return normalizeComponentRoot(vnode, instance.$parentVNode)
+ return normalizeComponentRoot(
+ vnode,
+ instance.$parentVNode,
+ instance.$options.inheritAttrs
+ )
}
export function teardownComponentInstance(instance: MountedComponent) {
export function normalizeComponentRoot(
vnode: any,
- componentVNode: VNode | null
+ componentVNode: VNode | null,
+ inheritAttrs: boolean | void
): VNode {
if (vnode == null) {
vnode = createTextVNode('')
(flags & VNodeFlags.COMPONENT || flags & VNodeFlags.ELEMENT)
) {
const parentData = componentVNode.data
- if (parentData != null) {
+ if (parentData != null && inheritAttrs !== false) {
let extraData: any = null
for (const key in parentData) {
// attrs/class/style bindings on parentVNode are merged down to child
// functional component
const subTree = (vnode.children = normalizeComponentRoot(
(tag as FunctionalComponent)(data || EMPTY_OBJ, slots || EMPTY_OBJ),
- vnode
+ vnode,
+ (tag as FunctionalComponent).inheritAttrs
))
el = vnode.el = mount(subTree, null, parentComponent, isSVG, null)
}
if (shouldUpdate) {
const nextTree = (nextVNode.children = normalizeComponentRoot(
render(nextProps || EMPTY_OBJ, nextSlots || EMPTY_OBJ),
- nextVNode
+ nextVNode,
+ render.inheritAttrs
))
patch(prevTree, nextTree, container, parentComponent, isSVG)
nextVNode.el = nextTree.el