Skip to content

Commit

Permalink
fix(model): fix static input type being overwritten by v-bind object (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored and yyx990803 committed Mar 13, 2018
1 parent 6dd73e9 commit a6169d1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/platforms/web/compiler/modules/model.js
Expand Up @@ -34,7 +34,7 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
if (map[':type'] || map['v-bind:type']) {
typeBinding = getBindingAttr(el, 'type')
}
if (!typeBinding && map['v-bind']) {
if (!map.type && !typeBinding && map['v-bind']) {
typeBinding = `(${map['v-bind']}).type`
}

Expand Down
11 changes: 11 additions & 0 deletions test/unit/features/directives/model-checkbox.spec.js
Expand Up @@ -337,4 +337,15 @@ describe('Directive v-model checkbox', () => {
expect(vm.$el.children[1].textContent).toBe('false')
}).then(done)
})

// #7811
it('type should not be overwritten by v-bind', () => {
const vm = new Vue({
data: {
test: true
},
template: '<input type="checkbox" v-model="test" v-bind="$attrs">'
}).$mount()
expect(vm.$el.type).toBe('checkbox')
})
})

0 comments on commit a6169d1

Please sign in to comment.