-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
enable implicit event (v-on) and var (v-bind) declarations: e.g. <a @click :title>hello!</a> #9253
Comments
Duplicate of #5835 |
@posva I see that the other issues referenced v-bind not events. The arguments are likely valid for properties (but that's neither here nor there) but events are not mentioned in those requests (or did I miss that?) and I submit to you that the boolean-ness of those is not applicable (so argument becomes less relevant, for events). If so, I'd like to propose that for events (at least, since the object notation does cannot apply since it's a function/method) maybe we consider re-opening this? As incentive, I went ahead and forked the source and added only a few lines to make this possible, as per below, in the html-parser.js module (inside the handleStartTag function). Here's a brief snippet:
[please note: this is UNTESTED (testing proceeding as we speak)] |
yeah, same reasons apply even though events are not mentioned 🙂 |
What problem does this feature solve?
make template html more DRY by reducing simple component (self-evident?) definitions.
Many times I find that I declare event methods using the same name as the underlying event, such as
(where
click
andmouseover
are of course defined as methods for the component, andtitle
is declared within the data() object).A cleaner way to do this (imho, and in keeping with javascript's shorthand object notation: e.g. const x = { a, b, c }), a cleaner way may look like this:
This concept could also be extended to binding of variables & props (e.g. :title=title becomes :title).
What does the proposed API look like?
the API would not (should not need to) be changed as this would affect only the initial parsing of a template's html.
I suspect the parts of the code to be modified would be here and here but those were too involved for me to attempt.
The text was updated successfully, but these errors were encountered: