Skip to content

Commit

Permalink
fix(model): fix static input type being overwritten by v-bind object (v…
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored and aJean committed Aug 19, 2020
1 parent 63f1b9b commit 228d1ca
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 228d1ca

Please sign in to comment.