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
Add v-on:keyup.enter to JSX #59
Comments
@LinusBorg, I've seen that you respond to questions like "How to use @event.modifier in JSX?" pretty often, do you think this idea is legit? P.S. we can do transforms without affecting other render (h) {
return <div onKeyup.enter={this.something} onKeyup.delete={this.somethingElse} />
} render (h) {
return h('div', {
on: {
keyup (event) {
if (/* check for enter */) this.something(event)
if (/* check for delete */) this.somethingElse(event)
}
}
}
} This would be a change in this repo only and it would allow people to use event modifiers directly in jsx. |
@QingWei-Li, @yyx990803, @LinusBorg. Hey, unfortunately class A {
render () {
return (
<div some_thing="somethingelse">
<input type="text"
onKeypress__enter={this.someMethod}
onKeypress__backspace={this.someOtherMethod}
onClick__prevent={this.smth} />
</div>
)
}
} I mad a POC and it works. |
You can see POC and play with it here: https://astexplorer.net/#/gist/78dff39789a6abaa879cea1d29f75e16/3806404f6e9ced30a99ef9d3e248acccde27af55 |
I like the POC! It kinda sucks that we can't get the syntax to align with the template version, but I can't seem to come up with a better alternative... (the only other char that can be used inside a JSX identifier is |
@yyx990803, maybe we can convince the babylon team to accept dot as a part of JSX identifier? I'll try to do a PR for them. |
@yyx990803 I have made a POC with XML's namespaces, using dot is a bad idea because it will result in invalid XML. Chaining doesn't work but I think about supporting things like P.S. I know it is totally opposite from what is colon and dot used in vue's template syntax but I guess JSX should be different. P.P.S. I think it should not be a part of this plugin, it should be a separate one because it is valid for any JSX and is not limited to Vue. |
@nickmessing I like the namespaced version - and yeah I agree it should probably be a separate plugin. |
@nickmessing semicolons are not valid in JSX.. |
@eakarpov, yes, semicolons ( As you can see in the spec: https://facebook.github.io/jsx/ P.S. this project and all sugars now live here: https://github.com/vuejs/jsx |
We could do something like:
to support the event modifiers, what do you think @yyx990803, @QingWei-Li, does it make any sense to you ?
The text was updated successfully, but these errors were encountered: