Skip to content

Commit

Permalink
fix: skip v-model & value binding collision check with dynamic type b…
Browse files Browse the repository at this point in the history
…inding (vuejs#7406)

* fix vuejs#7404
  • Loading branch information
Justineo authored and hefeng committed Jan 25, 2019
1 parent ed8537d commit f4eb76d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platforms/web/compiler/directives/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ function genDefaultModel (
const type = el.attrsMap.type

// warn if v-bind:value conflicts with v-model
// except for inputs with v-bind:type
if (process.env.NODE_ENV !== 'production') {
const value = el.attrsMap['v-bind:value'] || el.attrsMap[':value']
if (value) {
const typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']
if (value && !typeBinding) {
const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'
warn(
`${binding}="${value}" conflicts with v-model on the same element ` +
Expand Down
11 changes: 11 additions & 0 deletions test/unit/features/directives/model-text.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ describe('Directive v-model text', () => {
expect('conflicts with v-model').not.toHaveBeenWarned()
})

it('should not warn on input with dynamic type binding', () => {
new Vue({
data: {
type: 'checkbox',
test: 'foo'
},
template: '<input :type="type" v-model="test" :value="test">'
}).$mount()
expect('conflicts with v-model').not.toHaveBeenWarned()
})

if (!isAndroid) {
it('does not trigger extra input events with single compositionend', () => {
const spy = jasmine.createSpy()
Expand Down

0 comments on commit f4eb76d

Please sign in to comment.