-
Notifications
You must be signed in to change notification settings - Fork 546
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
v-bind merge strategy modifier #215
base: master
Are you sure you want to change the base?
Conversation
I agree on not relying on order to decide the outcome of combining Regarding |
This RFC is actually a breaking change for current Vue 3 users and I didn't find any solution to fix order dependency that would still not be a breaking change.
I think It is a handy tool to provide default values for element attributes. You would have to filter them out otherwise or define that value for each attribute. <!--these are equal-->
<input :disabled="'disabled' in $attrs ? $attrs.disabled : 'disabled'" v-bind="$attrs">
<input disabled v-bind.replace="$attrs"> But if only Vue 2 behaviour is retained (omitting the |
the attribute order argument is well understandable, but then how much is it worth, when in some other common vue practices HTML/XML consistency is not followed either (case-sensitive v-on, PascalCase tag names). personally i have a lot of use cases like component wrappers, where you want to pass through attrs and have some default attributes set (overwriteable), but also have some non-overwriteable attributes, which would end up in code like this: <template>
<wrapped-component v-bind="{ a: 'default-value-for-a', ...$attrs }" b="some-fixed-value-for-b" />
</template> with the current vue 3 behavior, this can be rewritten as the more concise: <template>
<wrapped-component a="default-value-for-a" v-bind="$attrs" b="some-fixed-value-for-b" />
</template> the question remains, if it is worth the BC break (compared to vue 2). regarding |
Consider this: when we do not have any reliance on the attribute order the complexity of managing an element\component grows linearly with the amount of attributes used. When we have attribute order that complexity grows exponentially, since you now how to scan every single attribute in order to get a full understanding of what's going on. I don't think its worth that mental overhead. |
I've never found myself in a scenario where I was binding something dynamically that I wanted to be overridden by an attribute. Sometimes I'll spread into an object I'm binding, but usually a v-bind and a prop and the same time means to me that local state is overriding a default. Why not just add a modifier such as |
v-bind
merge behaviour to the one used in Vue 2..replace
modifier to force attribute replacement.Rendered RFC