Subscribe on changes!

Warning when emitting kebab-cased custom event

avatar
Oct 15th 2021

Version

3.2.20

Reproduction link

sfc.vuejs.org

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))

avatar
Oct 15th 2021

I tested your code outside of the SFC and there is no warning at all. Are you sure you were not using defineEmits()?

avatar
Oct 15th 2021

updated SFC

sorry for the failing SFC earlier

avatar
Feb 24th 2022

I can reproduce this, but I see there is already a PR :tada: Is it planned to get released soon?