Subscribe on changes!

useAttrs in setup mode doesn't include listeners

avatar
Sep 30th 2021

Version

3.2.19

Reproduction link

sfc.vuejs.org/

Steps to reproduce

add a listener to a component import and try to console log the attrs using useAttrs

What is expected?

The listener will be added to the attrs

What is actually happening?

listeners are not included in attrs


refs:

https://v3.vuejs.org/guide/migration/listeners-removed.html#overview

https://v3.vuejs.org/api/sfc-script-setup.html#defineexpose

avatar
Sep 30th 2021

The listener will appear if you don't define it with defineEmits(). This is intended.

avatar
Sep 30th 2021

@posva Thanks for the reply!

The use case I have is that I basically want to use this function-prop also as a flag and not having to pass another prop. At the same time, I don't want to lose the typings of the emit.

Can this decision be reconsidered somehow?

avatar
Sep 30th 2021

You could use a prop. Changing this would be a breaking change and the rationale was discussed in the RFC (rfcs repo)