Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning when emitting kebab-cased custom event #4803

Closed
benkroeger opened this issue Oct 15, 2021 · 3 comments · Fixed by #11489
Closed

Warning when emitting kebab-cased custom event #4803

benkroeger opened this issue Oct 15, 2021 · 3 comments · Fixed by #11489
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior. 🐞 bug Something isn't working

Comments

@benkroeger
Copy link

benkroeger commented Oct 15, 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))

@posva
Copy link
Member

posva commented Oct 15, 2021

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

@posva posva added the need more info Further information is requested label Oct 15, 2021
@benkroeger
Copy link
Author

benkroeger commented Oct 15, 2021

updated SFC

sorry for the failing SFC earlier

@posva posva added 🧹 p1-chore Priority 1: this doesn't change code behavior. 🐞 bug Something isn't working and removed need more info Further information is requested labels Oct 18, 2021
@Shinigami92
Copy link
Contributor

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior. 🐞 bug Something isn't working
Projects
None yet
3 participants