-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
functional component wrapping with context.data causes v-model to update twice #8436
Comments
Yeah, both shouldn't be passed, only return h('base-input', { model: ctx.data.model }) |
I thought v-model was supposed to be syntactic sugar, why does it have a separate undocumented property on VNodeData? Does it make a difference if I pass through |
Turns out someone was relying on |
Yes, us included. We rely on it to inject server side validation on a Vuetify input. |
prevent double v-model update on functional components by not transforming model when Ctor.options.functional is true fix vuejs#8436
I'm worried that removing the listener and prop binding like in #8580 ends up in a less flexible approach: what if users want to use the listener + binding instead of model? |
Do you mean using |
Or using |
Tested it on #8580, it works for all 3 cases (without double update):
Maybe later I should write some unit tests to demonstrate it. |
Here's my solution until this is fixed in vue: function dedupeModelListeners (data: VNodeData): void {
if (data.model && data.on && data.on.input) {
if (Array.isArray(data.on.input)) {
const i = data.on.input.indexOf(data.model.callback)
if (i > -1) data.on.input.splice(i, 1)
} else {
delete data.on.input
}
}
} |
the condition is no longer necessary after reverting back to microtask only nextTick implementation, and fix #8436
This happens when a component directly passes down its own data object to a child component. Fix vuejs#8436.
the condition is no longer necessary after reverting back to microtask only nextTick implementation, and fix vuejs#8436
This happens when a component directly passes down its own data object to a child component. Fix vuejs#8436.
Version
2.5.16
Reproduction link
https://codepen.io/anon/pen/LrMKMg?editors=1011
Steps to reproduce
type in the input
What is expected?
'input'
should be logged onceWhat is actually happening?
'input'
is logged twiceUncomment
delete ctx.data.model
and it works fineOriginal pen using vuetify: https://codepen.io/anon/pen/QxzXYK?editors=1011
The text was updated successfully, but these errors were encountered: