-
Notifications
You must be signed in to change notification settings - Fork 547
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
Transparent v-model #21
Conversation
I don't think this is a good idea, mostly because of the implicit behaviour and there would be no idea to opt out unless it was a modifier or option in the component. I would rather see something on the prop itself than v-model, so that if the prop is assigned to a new value, it emits an event. This also intersects with #10 which is in part also addressing the same issue and could be solved by adding a plugin that reads an option from props like |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
What do you mean by implicit behavior? Wrapping components is a common use-case and so is wrapping model-exposing components. The boilerplate to wrap model-exposing components is even used in the vue guide https://vuejs.org/v2/guide/components-custom-events.html#Customizing-Component-v-model. And then you only have the basic handling, which does not respect keyed models or dynamic components. |
implicit as being something that happens without user consent, passing a prop to v-model could be a mistake on the dev's end while they meant to use |
Thats the tradeoff for expressiveness, isnt it? We could make it explicit: const child = {
model: {
// ...
transparent: true,
},
// ...
}; edit: I rather see the mixup in |
To still have an indication for data/prop mixups, we could provide a dev runtime notice, in case there is no listener for the update event in the parent (and therefore the bound model would never update anywhere). |
To build on this how about an option for forwarding events? Something like
in the js instead of
in the template. Sometimes you end up writing code like that 3 components deep just to get events where they need to be. |
Forwarding events can be dealt with by the developer with a reusable function, doesn't have to be solved on the API level. |
After reviewing the comments so far and a round of voting among core team members, we believe this is not something we will be implementing. Thanks for submitting your idea though! |
Rendered