Skip to content

Add support for v-on="$listeners" (#89) #90

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 2 commits into from
Jul 19, 2017

Conversation

armano2
Copy link
Contributor

@armano2 armano2 commented Jul 17, 2017

this pull request fixes #89 and vuejs/vetur#339

@nickmessing
Copy link
Member

Theoretically we could use something like:

<template>
  <button v-on="listeners">Hey</button>
</template>
<script>
export default {
  data: () => ({ // doesn't have to be in data, just an example
    listeners: {
      click: someFn,
      keyup: someOtherFn
    }
  })
}
</script>

And it is valid in Vue starting with 2.4.0. This is a bad pattern most of the time but sometimes it could be useful like having a computed property that removes click from $listeners but has anything else.

Do we consider that?

@armano2
Copy link
Contributor Author

armano2 commented Jul 17, 2017

@nickmessing Not in this PR, but for now Vue itself doesn't support this syntax (or maybe i understand this incorrectly)

https://vuejs.org/v2/api/#vm-listeners

In case when we can pass wathever object we like to, this rule is not valid anymore and should be removed.
'v-on' directives require event names.

@nickmessing
Copy link
Member

@armano2, vue does support that so I am not sure this rule is valid anymore, here's an example: https://jsfiddle.net/z8y5fpx6/

@armano2
Copy link
Contributor Author

armano2 commented Jul 18, 2017

thank you for clarification, part of this rule has been removed

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you so much!

@mysticatea mysticatea merged commit 7904536 into vuejs:master Jul 19, 2017
@armano2 armano2 deleted the patch-13-v-on=listeners branch July 19, 2017 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for v-on="$listeners"
3 participants