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

kebab-case events are attached as lower case on web components #2841

Closed
lee-orr opened this issue Dec 17, 2020 · 6 comments · Fixed by #2847
Closed

kebab-case events are attached as lower case on web components #2841

lee-orr opened this issue Dec 17, 2020 · 6 comments · Fixed by #2847
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working

Comments

@lee-orr
Copy link

lee-orr commented Dec 17, 2020

Version

3.0.4

Reproduction link

https://jsfiddle.net/meo9Lfya/3/

Steps to reproduce

  • Open: https://jsfiddle.net/meo9Lfya/3/
  • click the "click lower case" button - notice the text to the right of the buttons changes to "Clicked lower"
  • click the "click kebab case" button

What is expected?

The text to the right of the buttons should change to "Clicked kebab"

What is actually happening?

The text to the right of the buttons doesn't change


To confirm it was an issue with vue binding to the event, I added a "Mount Native Event Listeners" - if you click this button, it'll attach event listeners using addEventListener - and the buttons will both work as expected.

Note - this is utilizing vue 3.0.4, but I was seeing the same issue in 3.0.2 in my project, which relies on Vite.

Also - might be similar to: #2429 - however it's happening on newer versions of Vue...

@shadowings-zy
Copy link
Contributor

That's because the kebab-case custom event foo-bar in web components will parse to foobar. Vue will add foobar as the name of event listener. I think this needs a fix.

@posva posva changed the title kebab-case events are not triggered kebab-case events are attached as lower case on web components Dec 18, 2020
@lee-orr
Copy link
Author

lee-orr commented Dec 19, 2020

Thanks for the quick catch/solve! Hopefully it gets into the next release.

@toams69
Copy link

toams69 commented Jan 21, 2021

What is the state of this PR ?
I am facing the same issue using vue 3.0.5.
I can't catch event from webcomponent having a dash as name.
Even if I am using camelcase instead of keba case

@devmount
Copy link

devmount commented Jan 25, 2021

Same here. I'm using Shoelace webcomponents with the current Vue 3.0.5 and can't catch events like sl-show from it.
I've created a minimal working example and also described it at shoelace-style/shoelace#310.

@posva posva added 🐞 bug Something isn't working ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Jan 25, 2021
@recamshak
Copy link

recamshak commented Jan 29, 2021

As a workaround you can replace <sl-form @sl-submit="submit"> with <sl-form v-on="{ 'sl-submit': submit }">. Here is a fix of @devmount example: https://jsfiddle.net/faqp40th/

@devmount
Copy link

@recamshak Didn't know about that syntax, it's working, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants