-
-
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
test($compile): #7048 warn if both v-model and v-bind:value used on same element #7056
Conversation
src/compiler/parser/index.js
Outdated
(!map['type'] || map['type'] === 'text') | ||
) { | ||
var vBind = map['v-bind:value'] ? 'v-bind:value' : ':value' | ||
warn('v-model and ' + vBind + ' used on the same text input') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could definitely use a more detailed message here - something like "v-bind:value conflicts with v-model on the same element because the latter already expands to a value binding internally"
src/compiler/parser/index.js
Outdated
process.env.NODE_ENV !== 'production' && | ||
map['v-model'] && | ||
(map['v-bind:value'] || map[':value']) && | ||
(!map['type'] || map['type'] === 'text') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning should apply to anything that is not:
- type=checkbox
- type=radio
- select
Thanks for the feedback @yyx990803 Those changes have now been made. Do you think the tests are sufficient? |
src/compiler/parser/index.js
Outdated
) { | ||
var vBindValue = map['v-bind:value'] ? 'v-bind:value' : ':value' | ||
warn(vBindValue + ' conflicts with v-model on the same element because the latter already expands to a value binding internally') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check looks good now - but I'm not sure if makeAttrsMap
is the best place to do this check. Let's place it here since this warning is about v-model
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, it's now been moved
…js#7056) * test($compile): warn if v-model and :value used on same text input vuejs#7048 * test($compile): make v-model and v-bind:value warning apply to all but exceptions vuejs#7048 * test($compile): move v-model/:value conflict warner to model.js vuejs#7048 * style: split long warning messages onto new lines
…js#7056) * test($compile): warn if v-model and :value used on same text input vuejs#7048 * test($compile): make v-model and v-bind:value warning apply to all but exceptions vuejs#7048 * test($compile): move v-model/:value conflict warner to model.js vuejs#7048 * style: split long warning messages onto new lines
…js#7056) * test($compile): warn if v-model and :value used on same text input vuejs#7048 * test($compile): make v-model and v-bind:value warning apply to all but exceptions vuejs#7048 * test($compile): move v-model/:value conflict warner to model.js vuejs#7048 * style: split long warning messages onto new lines
Address issue #7048
I don't have much experience with contributing so any feedback would be very welcome.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)