File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
src/directives/public/model
test/unit/specs/directives/public Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,16 @@ export default {
3131 }
3232
3333 this . listener = function ( ) {
34- var model = self . _watcher . value
34+ var model = self . _watcher . get ( )
3535 if ( isArray ( model ) ) {
3636 var val = self . getValue ( )
37+ var i = indexOf ( model , val )
3738 if ( el . checked ) {
38- if ( indexOf ( model , val ) < 0 ) {
39- model . push ( val )
39+ if ( i < 0 ) {
40+ self . set ( model . concat ( val ) )
4041 }
41- } else {
42- model . $remove ( val )
42+ } else if ( i > - 1 ) {
43+ self . set ( model . slice ( 0 , i ) . concat ( model . slice ( i + 1 ) ) )
4344 }
4445 } else {
4546 self . set ( getBooleanValue ( ) )
Original file line number Diff line number Diff line change @@ -185,11 +185,13 @@ describe('v-model', function () {
185185 el . firstChild . click ( )
186186 expect ( vm . list . length ) . toBe ( 2 )
187187 expect ( vm . list [ 1 ] ) . toBe ( 1 )
188- vm . list = [ vm . a ]
189188 _ . nextTick ( function ( ) {
190- expect ( el . firstChild . checked ) . toBe ( false )
191- expect ( el . lastChild . checked ) . toBe ( true )
192- done ( )
189+ vm . list = [ vm . a ]
190+ _ . nextTick ( function ( ) {
191+ expect ( el . firstChild . checked ) . toBe ( false )
192+ expect ( el . lastChild . checked ) . toBe ( true )
193+ done ( )
194+ } )
193195 } )
194196 } )
195197
You can’t perform that action at this time.
0 commit comments