Skip to content

Component mounted with mountSuspended emits events twice after setProps was called #1176

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

Open
sebbayer opened this issue Mar 7, 2025 · 0 comments

Comments

@sebbayer
Copy link

sebbayer commented Mar 7, 2025

Environment


  • Operating System: Linux
  • Node Version: v18.20.3
  • Nuxt Version: 3.15.4
  • CLI Version: 3.22.4
  • Nitro Version: 2.11.3
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, compatibilityDate
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-4czkz34t?file=components%2FMyComponent.vue,test%2FMyComponent.test.js

Describe the bug

After using setProps in a component mounted with mountSuspended, using $emit inside a method will emit the event twice, which can be checked with wrapper.emitted(). This behaviour does not exist when using mount(). Please see reproduction link.

A workaround is to use the $emit directly in the @click attribute, like this:

<button @click="$emit('test', 'a')">test</button>

But this is not sufficient if a method needs to be called that does other things as well besides emitting.

Additional context

No response

Logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant