Warning when emitting kebab-cased custom event
Version
3.2.20
Reproduction link
Steps to reproduce
Open SFC
What is expected?
no warning to be logged as component defined onNewValue
prop
What is actually happening?
warning in console:
Component emitted event "new-value" but it is neither declared in the emits option nor as an "onNew-value" prop.
Having a component that emits a kebab-cased event (e.g. new-value
as in Quasar's QSelect
), you see the following warning:
Component emitted event "new-value" but it is neither declared in the emits option nor as an "onNew-value" prop.
The component actually defines a prop named onNewValue
- without listing new-value
in the component's emits
property.
It looks like this is due to the toHandlerKey helper only capitalizes the event name - which then only converts the first character to UPPERCASE.
Conventions done't allow non-camelized properties - so I think the toHandlerKey
actually needs to capitalize(camelize(str))
I tested your code outside of the SFC and there is no warning at all. Are you sure you were not using defineEmits()
?
updated SFC
sorry for the failing SFC earlier