Skip to content

feat: pass listeners to functional components #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: use context for listeners and scoped slots
  • Loading branch information
eddyerburgh committed Nov 23, 2018
commit 42307515218854e71b4e6795dcbedf18658c4d41
19 changes: 15 additions & 4 deletions packages/create-instance/create-functional-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@ export default function createFunctionalComponent (
validateSlots(mountingOptions.slots)
}

const data = mountingOptions.context ||
component.FunctionalRenderContext || {}
data.scopedSlots = createScopedSlots(mountingOptions.scopedSlots)
const context =
mountingOptions.context ||
component.FunctionalRenderContext ||
{}

const listeners = mountingOptions.listeners

if (listeners) {
Object.keys(listeners).forEach(key => {
context.on[key] = listeners[key]
})
}

context.scopedSlots = createScopedSlots(mountingOptions.scopedSlots)

return {
render (h: Function) {
return h(
component,
data,
context,
(mountingOptions.context &&
mountingOptions.context.children &&
mountingOptions.context.children.map(
Expand Down