Unclear/misleading rules for prop/event name conversion #7270
Unanswered
Kasheftin
asked this question in
Help/Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Vue version
3.2.45
Link to minimal reproduction
https://kasheftin.github.io/vue3-prop-name-conversion/
SFC Playground
Steps to reproduce
Here's the repo: https://github.com/Kasheftin/vue3-prop-name-conversion/blob/master/src/App.vue
If an event is specified in kebab-case (like
:on-some-event
), it does not work.What is expected?
The regular props in both vue2 and vue3 can be defined both in kebab case and in camel case,
:some-prop
works as well as:someProp
. Prop name is auto converted to camel case. It's expected that an event, defined in a form of a prop,:on-some-event
, should be auto converted to :onSomeEvent as well. But it does not happen.What is actually happening?
if an event is defined in a form of a prop,
:on-some-event
, then it's not possible to trigger it using$emit('..anything..')
.System Info
Any additional comments?
It's not a bug. It's more like a question - why this specific case is not auto converted. We know (from vue2) that listeners are not auto convered, that's why it was a surprise to discover that
@some-event
,@someEvent
and even@SomeEvent
- everything is working. It's natural to expect that an event, defined in a form of a prop,:on-some-event
will inherit prop name conversion and it will be possible to trigger it, but it's not.Beta Was this translation helpful? Give feedback.
All reactions