Subscribe on changes!

use of `arguments` inline with Vue event handler results in error `ReferenceError: arguments is not defined`

avatar
Jan 14th 2021

Version

3.0.5

Reproduction link

https://jsfiddle.net/osxLw5p9/

Steps to reproduce

Use arguments inline, in the events handler body, and then emit an event up to trigger the handler.

Example: <component @my-event="handleEvent('thing', ...arguments)" />

What is expected?

arguments is accessible (per past Vue 2 functionality).

Or, a note in migration guide about arguments inaccessible in Vue 3.

What is actually happening?

arguments not defined error.


In the past arguments has been mentioned as a way to access arbitrary parameters, e.g. through spread operator:

https://github.com/vuejs/vue/issues/5527#issuecomment-297600033

avatar
Jan 14th 2021

The genearted code uses an arrow function. You should use <component @my-event="(...args) => handleEvent('thing', ...args)" />. I would say this should be documented

avatar
Jan 14th 2021

I would say this should be documented

Definitely, should be added to the migration guide since it's a 2 -> 3 breaking change.

avatar
Jul 5th 2022

We welcome a PR to the docs.