From f9991b563c23bc23293fe88def3a0676cf2bcebe Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Tue, 13 Mar 2018 18:06:29 +0900 Subject: [PATCH 1/2] fix(model): Static type="checkbox" was being ignored when used with v-bind fix #7811 --- src/platforms/web/compiler/modules/model.js | 2 +- test/unit/features/directives/model-checkbox.spec.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/platforms/web/compiler/modules/model.js b/src/platforms/web/compiler/modules/model.js index a7426c0204f..8d784fe4695 100644 --- a/src/platforms/web/compiler/modules/model.js +++ b/src/platforms/web/compiler/modules/model.js @@ -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` } diff --git a/test/unit/features/directives/model-checkbox.spec.js b/test/unit/features/directives/model-checkbox.spec.js index e102af62609..7f03823618a 100644 --- a/test/unit/features/directives/model-checkbox.spec.js +++ b/test/unit/features/directives/model-checkbox.spec.js @@ -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: '' + }).$mount() + expect(vm.$el.type).toBe('checkbox') + }) }) From 01223f1823b0304399f4c3554919bcba350b68f6 Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 13 Mar 2018 11:05:24 -0400 Subject: [PATCH 2/2] Update model-checkbox.spec.js --- test/unit/features/directives/model-checkbox.spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/unit/features/directives/model-checkbox.spec.js b/test/unit/features/directives/model-checkbox.spec.js index 7f03823618a..2b73e23d302 100644 --- a/test/unit/features/directives/model-checkbox.spec.js +++ b/test/unit/features/directives/model-checkbox.spec.js @@ -337,8 +337,9 @@ describe('Directive v-model checkbox', () => { expect(vm.$el.children[1].textContent).toBe('false') }).then(done) }) - - it('should have type="checkbox"', () => { + + // #7811 + it('type should not be overwritten by v-bind', () => { const vm = new Vue({ data: { test: true