Skip to content

Commit 9c4bf35

Browse files
committed
make v-model checkbox replace array instead of mutating it
1 parent 609054e commit 9c4bf35

File tree

1 file changed

+2
-2
lines changed
  • src/platforms/web/compiler/directives

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ function genCheckboxModel (el: ASTElement, value: ?string) {
5252
'if(Array.isArray($$a)){' +
5353
`var $$v=${valueBinding},` +
5454
'$$i=$$a.indexOf($$v);' +
55-
'if($$c){$$i<0&&$$a.push($$v)}' +
56-
'else{$$i>-1&&$$a.splice($$i,1)}' +
55+
`if($$c){$$i<0&&(${value}=$$a.concat($$v))}` +
56+
`else{$$i>-1&&(${value}=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}` +
5757
`}else{${value}=$$c}`
5858
)
5959
}

0 commit comments

Comments
 (0)