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

Emitting event with cabeb-case name format doesn't work #2526

Closed
boussadjra opened this issue Oct 30, 2020 · 8 comments
Closed

Emitting event with cabeb-case name format doesn't work #2526

boussadjra opened this issue Oct 30, 2020 · 8 comments

Comments

@boussadjra
Copy link

Version

3.0.2

Reproduction link

https://codesandbox.io/s/emit-with-camel-case-issue-tsqn0?file=/src/components/Child.vue

Steps to reproduce

I have a Child component in which I emit an event to the parent component Container with cabeb-case name format:

export default defineComponent({
  name: "Child",
  emits: ["enlarge-text"],
  methods: {
    tryThis() {
      console.log("trying");
      this.$emit("enlarge-text", "someValue");
    },
  },
});

in parent :

    <Child @enlarge-text="onEnlargeText" />
  ....
  methods: {
    onEnlargeText() {
      console.log("enlarging text");
    },
  },

What is expected?

i expect that the emitted event should be fired in parent component

What is actually happening?

this doesn't fire the event, but if I change the name to camelCase format it works fine


The linter doesn't accept the camelCase named event

I remarked this after trying to answer this question on Stackoverflow

@edison1105
Copy link
Member

see #2429

@edison1105
Copy link
Member

<Child @EnlargeText="onEnlargeText" />

works

@boussadjra
Copy link
Author

<Child @EnlargeText="onEnlargeText" />

works

Yes it works but the linter raises a warning

@vhoyer
Copy link

vhoyer commented Oct 30, 2020

image
it doesn't raise a warning for me 🤔

@edison1105
Copy link
Member

@boussadjra
Copy link
Author

image
it doesn't raise a warning for me 🤔

@vhoyer i'm talking about the camelCase format which works but the linter raises a warning

@boussadjra
Copy link
Author

@edison1105 i updated that module to the version 3.0.2 but it's still not working

@69hunter
Copy link
Contributor

Hi @boussadjra I just peeked into the package-lock.json in your reproduction link. It seems that the @vue/compiler-sfc is at version 3.0.0. If you can try to upgrade the module to 3.0.2, it should work.

Screenshot 2020-10-30 at 11 26 35 PM

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

4 participants