Skip to content

Commit

Permalink
fix(model): Static type="checkbox" was being ignored when used with v…
Browse files Browse the repository at this point in the history
…-bind

fix vuejs#7811
  • Loading branch information
Hiroki Osame committed Mar 13, 2018
1 parent bc72e6c commit f9991b5
Show file tree
Hide file tree
Showing 2 changed files with 11 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
10 changes: 10 additions & 0 deletions test/unit/features/directives/model-checkbox.spec.js
Expand Up @@ -337,4 +337,14 @@ describe('Directive v-model checkbox', () => {
expect(vm.$el.children[1].textContent).toBe('false')
}).then(done)
})

it('should have type="checkbox"', () => {
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 f9991b5

Please sign in to comment.