From a6169d1eb71d64eacddf1738e72d21725e2bff00 Mon Sep 17 00:00:00 2001 From: Hiroki Osame Date: Wed, 14 Mar 2018 00:05:58 +0900 Subject: [PATCH] fix(model): fix static input type being overwritten by v-bind object (#7819) fix #7811 --- src/platforms/web/compiler/modules/model.js | 2 +- test/unit/features/directives/model-checkbox.spec.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/platforms/web/compiler/modules/model.js b/src/platforms/web/compiler/modules/model.js index a7426c020..8d784fe46 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 e102af626..2b73e23d3 100644 --- a/test/unit/features/directives/model-checkbox.spec.js +++ b/test/unit/features/directives/model-checkbox.spec.js @@ -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: '' + }).$mount() + expect(vm.$el.type).toBe('checkbox') + }) })