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

When templates are compiled at runtime, kebab-cased event names specified in emits don't prevent event listeners from being passed down via $attrs #2541

Closed
marzelin opened this issue Nov 2, 2020 · 1 comment

Comments

@marzelin
Copy link

marzelin commented Nov 2, 2020

Version

3.0.2

Reproduction link

https://codesandbox.io/s/reverent-wiles-u85ur?file=/src/main.js:140-160

Steps to reproduce

Having the code from the reproduction link:

import * as vue from "vue/dist/vue.esm-bundler.js";

const Inner = {
  template: `
    <button @click="logAttrs">log $attrs</button>
  `,
  emits: ["my-event"],
  methods: {
    logAttrs() {
      console.log(this.$attrs);
    }
  }
};

const App = {
  components: {
    Inner
  },
  template: `
    <Inner @my-event="noop" />
  `,
  methods: {
    noop() {}
  }
};

vue.createApp(App).mount("#app");
console.log({ "vue.version": vue.version });

click the log $attrs button to log this.$attrs.

What is expected?

this.$attrs should be empty since according to the docs placing event name in emits should prevent a listener for the event to fallthrough.

What is actually happening?

this.$attrs contains onMyEvent listener which means emits doesn't block it from being passed down.


Note: everything works as expected when templates are precompiled.

@LinusBorg
Copy link
Member

Source of the problem is the same as #2540

Will close this as a duplicate

@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 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

2 participants