vuejs / babel-plugin-transform-vue-jsx

babel plugin for vue 2.0 jsx
1.85k stars 132 forks source link

Support on={this.$listeners} #153

Open voluntadpear opened 6 years ago

voluntadpear commented 6 years ago

I'm not exactly sure if my intuition is OK but I was trying to pass the $listeners property to a specific element of my component doing this:

render () {
<div
  on={this.$listeners}
/>
}

And my app breaks with this:

Module build failed: TypeError: /Users/guille/Documents/vue-test/packages/dialog/src/index.js: Cannot read property 'toLowerCase' of undefined
    at groupEventAttributes (/Users/guille/Documents/vue-test/node_modules/babel-plugin-jsx-event-modifiers/dist/bundle.js:34:30)
    at Array.reduce (<anonymous>)

I did what was proposed on #86 and it works:

render () {
const attributes = {on: this.$listeners}

  <div
    {...attributes}
  />
}

Shouldn't we support the syntax of my first attempt?