You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: Use riot.js super easy event handlers #8
What about this <button on:click="handleClick({ foo: bar })">click me!</button> replace with this <button onclick="handleClick({ foo: bar })">click me!</button>
At the moment, elements and components have two types of 'thing': attributes and directives (three if you count spread attributes separately, I suppose). I don't personally think it's worth adding another type of thing that increases the complexity of the language for the sake of saving two characters. It's not a good idea to have multiple ways of doing something, because it creates anxiety in users, who end up asking themselves if one is 'correct', and if there are any differences in behaviour that they haven't understood. It just means more documentation, and the liberal use of @ is something that many people would find off-putting when first seeing HTMLx.
onclick is a native attribute whose use is discouraged (because it runs in the global scope, etc), so that's not really an option.
Reacted by Paulo Coghi, Max Milton, Robert Hall, Tomasz Błachut, Tony and Veit Kunz
Why can't HTMLx spec that onclick et al are scoped to the component? I really enjoyed coming to Riot and getting to use the real event attributes vs. idioms like v-on:click.
@jfbrennan as Rich Harris said, "is a native attribute"—i.e., if you override the native functionality, it won't be available. Idioms are just that: deliberately meant to set things apart as, in the e"x"tra in HTMLx.
Reacted by Paulo Coghi, Linus and Gabriel Francisco
Activity
arxpoetica commentedon May 3, 2018
Because
onclickis a native attribute and shouldn't be touched.https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Event_handlers
IamManchanda commentedon May 3, 2018
Can't it be just
@click,@keyup?or both
on:click&@clickwith anyone working!Yes Vue like!
arxpoetica commentedon May 3, 2018
I say no to both [update: I meant "both" as in "two forms"]. Pick one and stick with it.
+1 to
on:*IamManchanda commentedon May 3, 2018
@arxpoetica No I mean keep
on:*but also keep@*as shorthandRich-Harris commentedon May 3, 2018
At the moment, elements and components have two types of 'thing': attributes and directives (three if you count spread attributes separately, I suppose). I don't personally think it's worth adding another type of thing that increases the complexity of the language for the sake of saving two characters. It's not a good idea to have multiple ways of doing something, because it creates anxiety in users, who end up asking themselves if one is 'correct', and if there are any differences in behaviour that they haven't understood. It just means more documentation, and the liberal use of
@is something that many people would find off-putting when first seeing HTMLx.onclickis a native attribute whose use is discouraged (because it runs in the global scope, etc), so that's not really an option.vedam commentedon Nov 18, 2018
In addition, isn't
@something used in other libs meaning something else (i.e. mobx @observable)?IMO adding more confusion than value.
jfbrennan commentedon Dec 4, 2018
Why can't HTMLx spec that
onclicket al are scoped to the component? I really enjoyed coming to Riot and getting to use the real event attributes vs. idioms likev-on:click.arxpoetica commentedon Dec 6, 2018
@jfbrennan as Rich Harris said, "is a native attribute"—i.e., if you override the native functionality, it won't be available. Idioms are just that: deliberately meant to set things apart as, in the e"x"tra in HTMLx.