diff --git a/src/v2/guide/render-function.md b/src/v2/guide/render-function.md index 75d4013b79..f3dda1c7c6 100644 --- a/src/v2/guide/render-function.md +++ b/src/v2/guide/render-function.md @@ -579,6 +579,24 @@ Vue.component('smart-list', { }) ``` +### Passing Attributes and Events to Child Elements/Components + +On normal components, attributes not defined as props are automatically added to the root element of the component, replacing or [intelligently merging with](class-and-style.html) any existing attributes of the same name. + +Functional components, however, require you to explicitly define this behavior: + +```js +Vue.component('my-functional-button', { + functional: true, + render: function (createElement, context) { + // Transparently pass any attributes, event listeners, children, etc. + return createElement('button', context.data, context.children) + } +}) +``` + +By passing `context.data` as the second argument to `createElement`, we are passing down any attributes or event listeners used on `my-functional-button`. It's so transparent, in fact, that events don't even require the `.native` modifier. + ### `slots()` vs `children` You may wonder why we need both `slots()` and `children`. Wouldn't `slots().default` be the same as `children`? In some cases, yes - but what if you have a functional component with the following children?