Skip to content
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

Alias for v-on and v-bind #9190

Closed
CyberAP opened this issue Dec 12, 2018 · 6 comments
Closed

Alias for v-on and v-bind #9190

CyberAP opened this issue Dec 12, 2018 · 6 comments

Comments

@CyberAP
Copy link

CyberAP commented Dec 12, 2018

What problem does this feature solve?

If you've decided to go with v-bind and v-on shorthands then v-on="$listeners" looks out of place and creates a mixture of syntax. Shorthands for v-on and v-bind would solve that issue.

What does the proposed API look like?

v-on="$listeners" should be aliased like this: @="$listeners"

v-bind="$attrs" should be aliased like this: :="$attrs"

@posva
Copy link
Member

posva commented Dec 12, 2018

I don't think this is a good idea, v-bind= and v-on= do not happen that often to offer a shorthand syntax that is confusing. Having the full text version makes things more readable since it's a v-bind or v-on without argument is so different from one with an argument. So I think having both v-bind and v-on is actually a good thing because they are visible (or out of place) while := and @= are not

@CyberAP
Copy link
Author

CyberAP commented Dec 12, 2018

One great thing about @ and : aliases is that they are instantly recognizable, and I couldn't say that about v-bind and v-on. I would say that it is one of the main reasons people prefer this syntax over the other.

@posva
Copy link
Member

posva commented Dec 12, 2018 via email

@CyberAP
Copy link
Author

CyberAP commented Dec 12, 2018

We'll have to agree to disagree on this one. For me mixing @click, @keyup listeners with v-on is hard to digest at a quick glance. Especially if I need to work with native elements' wrappers extensively. If we have all listeners and bindings align to the same semantics that would improve readability, since you don't have to search line by line through all the attributes.

This also goes well with official Vue style guide. Right now you're basically breaking the rule with these directives because you have no other option. The same applies to v-model, but that's another case.

@yunfeihuang
Copy link

v-on="myListeners" or @="myListeners" How to register native events?

@posva
Copy link
Member

posva commented Jan 29, 2019

As we discussed a shorthand for v-slot, we also talked about these shorthands not being in line with Vue values of being approachable and intuitive.

More at vuejs/rfcs#3 (comment)

@posva posva closed this as completed Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants