3.0.0-alpha.3
https://codesandbox.io/s/v-model-decomposed-camel-case-v337l
v-model to it.update:modelValue event. Everything should work as expected: https://codesandbox.io/s/v-model-on-component-pex6sv-model to :model-value="myText"
@update:modelValue="myText = $event"
The value won't update properly: https://codesandbox.io/s/v-model-decomposed-camel-case-v337l
As per RFC, everything should work fine with camelCased event name
When we decompose v-model to passed model-value prop and emitted update:modelValue event, it works only with kebab-cased event name.
Please check the discussion on https://github.com/vuejs/docs-next/pull/39#discussion_r370072027
This is actually because the use of in-DOM templates. The innerHTML is normalized by the browser and converts all attributes names to lowercase before Vue's compiler can handle it.
i.e. onUpdate:modelValue is converted to onUpdate:modelvalue, so the event names won't match.
When using in-dom templates, event names should also follow the kebab case convention:
<child-input
:model-value="myText"
@update:model-value="myText = $event"
></child-input>
In 2.x, a two-way binding via :model-value.sync automatically attaches listeners for both update:model-value and update:modelValue.
For consistency, in 3.0 we should allow update:modelValue event to trigger the handler of v-model:model-value.
After the fix:
For a prop named fooBar, the emitted events should always be consistent and use update:fooBar.
When using the component:
<child v-model:fooBar="xxx" /><child v-model:foo-bar="xxx" /> will also work.
Most helpful comment
After the fix:
For a prop named
fooBar, the emitted events should always be consistent and useupdate:fooBar.When using the component:
<child v-model:fooBar="xxx" /><child v-model:foo-bar="xxx" />will also work.