Closed thenickname closed 5 years ago
@thenickname, fair point, but I am not sure we want to convert all events to kebab-case
because if someone does this.$emit('camelCased')
it won't work. Maybe we could consider adding this to the core. @chrisvfritz, opinion here?
@nickmessing I agree we should fix this in core by creating both camelCase and kebab-case versions of all listeners. 🙂
@nickmessing Evan's reasoning in this issue makes sense to me, so I think we probably have to close this unfortunately. @thenickname While I like the idea, it would make some technically valid events impossible to listen for in JSX.
On the bright side, I've just submitted a proposal to the team to strictly enforce lowercase event names in Vue 3, which would solve this problem and many others related to events. 🎉
This is a suggestion to make event attribute names in JSX more consistent with other props and attributes. Among other things this would simplify providing event types for TSX and make better use of the already existing editor support (vscode)
The problem: If a vue component emits following event:
It is impossible to listen for it in JSX using
camelCase
:One is forced to do one of the following:
While the above examples do work, they are somewhat inconsistent with how all other JSX attributes are usually written. I belive it is more common to have all attributes
camelCase
.Also, when working with TSX in vscode, autocomplete suggestions for props are all
camelCase
. However, because vue events likecustom-event
do not translate toonCustomEvents
in JSX it makes things more difficult when working with Vue, TypeScript and TSX.