Skip to content

Commit f9991b5

Browse files
author
Hiroki Osame
committed
fix(model): Static type="checkbox" was being ignored when used with v-bind
fix vuejs#7811
1 parent bc72e6c commit f9991b5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/platforms/web/compiler/modules/model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function preTransformNode (el: ASTElement, options: CompilerOptions) {
3434
if (map[':type'] || map['v-bind:type']) {
3535
typeBinding = getBindingAttr(el, 'type')
3636
}
37-
if (!typeBinding && map['v-bind']) {
37+
if (!map.type && !typeBinding && map['v-bind']) {
3838
typeBinding = `(${map['v-bind']}).type`
3939
}
4040

test/unit/features/directives/model-checkbox.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,14 @@ describe('Directive v-model checkbox', () => {
337337
expect(vm.$el.children[1].textContent).toBe('false')
338338
}).then(done)
339339
})
340+
341+
it('should have type="checkbox"', () => {
342+
const vm = new Vue({
343+
data: {
344+
test: true
345+
},
346+
template: '<input type="checkbox" v-model="test" v-bind="$attrs">'
347+
}).$mount()
348+
expect(vm.$el.type).toBe('checkbox')
349+
})
340350
})

0 commit comments

Comments
 (0)