feat(v-model): add support for custom element form bindings with cust… #9883
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Vue does a great job with custom elements, but it doesn't have a way to specify which
v-model
type should be set for each custom element a user registers.Setting
app.config.compilerOptions.isCustomElement
works well for text input components where library authors can emit aninput
event and use avalue
prop, but we are unable to support checkboxes and radio buttons sinceV_MODEL_TEXT
is looking forevent.target.value
instead ofevent.target.checked
.The workaround is to set a type on the host element like this:
However, this is another step that users have to remember that could be globally set in the
compilerOptions
.Solution
Add a new option,
customElementType
that users can alongsideisCustomElement
. This will give users a way to select the correctv-model
type so that custom element libraries can begin supportingv-model
.close: #4428