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

#2278 causes kebab case listener not get triggered #2429

Closed
yaquawa opened this issue Oct 19, 2020 · 16 comments
Closed

#2278 causes kebab case listener not get triggered #2429

yaquawa opened this issue Oct 19, 2020 · 16 comments

Comments

@yaquawa
Copy link

yaquawa commented Oct 19, 2020

Version

3.0.1

Reproduction link

https://codesandbox.io/s/dreamy-khayyam-m06w1?file=/src/App.vue

Steps to reproduce

<foo @my-event-name="callEvent" />
this.$emit('my-event-name') // `callEvent` not triggered

What is expected?

The doc recommends using kebab case for event names, but #2278 breaks this.

https://v3.vuejs.org/guide/component-custom-events.html#event-names

What is actually happening?

After #2278 got merged, my code shown above won't work.

(You might want to write some tests before merge. Thanks!)

@posva
Copy link
Member

posva commented Oct 19, 2020

Your reproduction works...

@posva posva closed this as completed Oct 19, 2020
@yaquawa
Copy link
Author

yaquawa commented Oct 19, 2020

@posva have you clicked the "Hello Vue 3 in CodeSandbox!" ? If it works, the alert should appears.

@LinusBorg
Copy link
Member

LinusBorg commented Oct 19, 2020

@posva I don't get any alert from clicking on HelloWorld's body, can't say this works.

@LinusBorg LinusBorg reopened this Oct 19, 2020
@posva
Copy link
Member

posva commented Oct 19, 2020

Screen Shot 2020-10-19 at 13 04 48

Huh?

Edit: Forced updated the vue version and it doesn't work 👍

@Wizard67
Copy link

I'm having the same problem.

@LinusBorg LinusBorg added the 🐞 bug Something isn't working label Oct 19, 2020
@LinusBorg
Copy link
Member

LinusBorg commented Oct 19, 2020

Since #2278 now all events are camelCased, we now have to camelCase events everywhere, mainly in two places:

  1. when setting emitsOptions on the internal instanc
  2. during the call of emit(), the first argument.

/cc @yyx990803 this is a pretty broad regression from 3.0.0 and might need a hotfix release.

@07akioni
Copy link
Contributor

Docs may need an update too.

image

@LinusBorg
Copy link
Member

If we make the changes i mentioned, docs could stay as they are. Pascal-Case recommended, but camel case works as well.

@yyx990803
Copy link
Member

yyx990803 commented Oct 20, 2020

This works correctly in a reproduction using 3.0.1 global build (https://jsfiddle.net/yyx990803/3scy68d5/1/) and also works on a fresh vue-cli project using 3.0.1. There could be a compiler/runtime version mismatch in your project that doesn't properly camelize the event when emitting (make sure your @vue/compiler-sfc is also on 3.0.1).

Closing since it's not reproducible.

@yyx990803 yyx990803 removed the 🐞 bug Something isn't working label Oct 20, 2020
@yaquawa
Copy link
Author

yaquawa commented Oct 21, 2020

@LinusBorg @07akioni @posva can you guys confirm it's working on the iife version of vue >=3.0.1 ?

@posva
Copy link
Member

posva commented Oct 21, 2020

yes, it's working

@LinusBorg
Copy link
Member

@ttntm
Copy link

ttntm commented Oct 21, 2020

This works correctly in a reproduction using 3.0.1 global build (https://jsfiddle.net/yyx990803/3scy68d5/1/) and also works on a fresh vue-cli project using 3.0.1. There could be a compiler/runtime version mismatch in your project that doesn't properly camelize the event when emitting (make sure your @vue/compiler-sfc is also on 3.0.1).

Closing since it's not reproducible.

Thanks, this was really helpful.

Just updated a project I'm working on to 3.0.2 and ended up here because of events not firing/not being caught - npm update @vue/compiler-sfc fixed that.

@yaquawa
Copy link
Author

yaquawa commented Oct 22, 2020

Thanks guys, I don't know why, but it works now automatically...

@lee-orr
Copy link

lee-orr commented Dec 17, 2020

I'm still getting this issue w/ @vue/compiler-sfc 3.0.4 & vue 3.0.4. Was able to reproduce it in a JSFiddle that only relies on the unpkg dist for vue 3.0.4: https://jsfiddle.net/meo9Lfya/3/
You'll notice that the event works when clicking the "lowercase" button, but not the "kebab" button, but when using "addEventListener" on the element, both work.

@LinusBorg
Copy link
Member

Please open a new issue. This will get drowned out.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants