-
-
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
camelCased props bound through an object take precedence over a kebab cased specific prop #9641
Comments
Indeed, seems that the camelCase version always takes precedence. The expected behaviour would be the specific |
I was actually in the midst of submitting a PR to the API docs in the |
I forgot to say but this rings a bell but I couldn't find the issue/pr related but I'm pretty sure there was something already opened |
Version
2.6.8
Reproduction link
https://codesandbox.io/s/54v49n1nzn
Steps to reproduce
The repro shows the issue directly.
What is expected?
I wanted to know what takes precedence when something is bound using
v-bind={}
vs set explicitly as a prop. I would expect this to always be one or the other, or to be resolved in order of declaration as when merging objects in JS ({...boundProps, specificProp })What is actually happening?
The precedence is determined based on whether a prop has multiple words. duplicate keys are set by the object when they are declared in dash-case, and set by the prop/attribute if they are camelCase or a single word.
This can be made 'consistent' by declaring multiword props using camelcase, but that's against the recommendations in the styleguide which suggest using dash case for multiword props inside templates: https://vuejs.org/v2/style-guide/#Prop-name-casing-strongly-recommended.
I ran into this when an undefined value bound to a parent was overriding the same value explicitly set in the child, but it wasn't happening consistently depending on what the names of the props were.
The text was updated successfully, but these errors were encountered: