diff --git a/src/platforms/web/compiler/directives/model.js b/src/platforms/web/compiler/directives/model.js index 8f5951eac5..7c662629b6 100644 --- a/src/platforms/web/compiler/directives/model.js +++ b/src/platforms/web/compiler/directives/model.js @@ -93,7 +93,7 @@ function genCheckboxModel ( 'if(Array.isArray($$a)){' + `var $$v=${number ? '_n(' + valueBinding + ')' : valueBinding},` + '$$i=_i($$a,$$v);' + - `if($$el.checked){$$i<0&&(${value}=$$a.concat($$v))}` + + `if($$el.checked){$$i<0&&(${value}=$$a.concat([$$v]))}` + `else{$$i>-1&&(${value}=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}` + `}else{${genAssignmentCode(value, '$$c')}}`, null, true diff --git a/test/unit/features/directives/model-checkbox.spec.js b/test/unit/features/directives/model-checkbox.spec.js index 2c296ccbf5..e102af6260 100644 --- a/test/unit/features/directives/model-checkbox.spec.js +++ b/test/unit/features/directives/model-checkbox.spec.js @@ -161,6 +161,34 @@ describe('Directive v-model checkbox', () => { }).then(done) }) + it('bind to Array value with array value bindings (object loose equal)', done => { + const vm = new Vue({ + data: { + test: [{ a: 1 }] + }, + template: ` +