Subscribe on changes!

Object value coerced to string in event values

avatar
Jul 22nd 2021

Version

3.2.0-beta.4

Reproduction link

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8cD5cbiAgICBDaGFuZ2UgZWl0aGVyIGFuZCBjaGVjayB5b3VyIGxvZ3M6XG4gIDwvcD5cbiAgPHNlbGVjdCBAY2hhbmdlPVwibG9nXCI+XG4gICAgPG9wdGlvbiB2LWZvcj1cIm9wdGlvbiBpbiBvcHRpb25zXCIgOnZhbHVlPVwib3B0aW9uXCI+e3sgb3B0aW9uIH19PC9vcHRpb24+XG4gIDwvc2VsZWN0PlxuICA8YnIgLz5cbiAgPGlucHV0IHR5cGU9XCJjaGVja2JveFwiIDp2YWx1ZT1cInsgYTogJ0EnIH1cIiBAY2hhbmdlPVwibG9nXCIgaWQ9XCJhXCIgLz5cbiAgPGxhYmVsIGZvcj1cImFcIj4nQScgY2hlY2tib3g8L2xhYmVsPlxuPC90ZW1wbGF0ZT5cblxuPHNjcmlwdCBzZXR1cD5cbiAgY29uc3Qgb3B0aW9ucyA9IFtcbiAgICB7YTogXCJBXCIsIGI6IFwiQlwifSxcbiAgICB7YzogXCJDXCIsIGQ6IFwiRFwifSxcbiAgXTtcbiAgZnVuY3Rpb24gbG9nKGV2ZW50KSB7XG4gICAgY29uc29sZS5sb2coZXZlbnQpO1xuICAgIGNvbnNvbGUubG9nKGV2ZW50LnRhcmdldC52YWx1ZSk7IC8vIFNob3VsZCBwcmludCBhcyBhbiBPQkpFQ1QsIG5vdCBhcyBhIFNUUklOR1xuICAgIGNvbnNvbGUubG9nKFwiVmFsdWUgdHlwZTogXCIgKyB0eXBlb2YoZXZlbnQudGFyZ2V0LnZhbHVlKSlcbiAgfVxuPC9zY3JpcHQ+In0=

Steps to reproduce

  1. Create any input with an object-type value (E.g. <input type="checkbox" :value="{ a: 'A' }" />)
  2. Add a v-on:change value to the input
  3. Check typeof(event.target.value)

What is expected?

event.target.value should return the object specified in value (as is assumed at https://v3.vuejs.org/guide/component-custom-events.html#v-model-arguments ).

What is actually happening?

event.target.value returns the String "[object Object]".


When using components, and passing in a v-model, I intend to use $emit("update:modelValue", event.target.value) to pass the proper parameter as selected by a