File tree 2 files changed +12
-9
lines changed
src/directives/public/model
test/unit/specs/directives/public 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,16 @@ export default {
31
31
}
32
32
33
33
this . listener = function ( ) {
34
- var model = self . _watcher . value
34
+ var model = self . _watcher . get ( )
35
35
if ( isArray ( model ) ) {
36
36
var val = self . getValue ( )
37
+ var i = indexOf ( model , val )
37
38
if ( el . checked ) {
38
- if ( indexOf ( model , val ) < 0 ) {
39
- model . push ( val )
39
+ if ( i < 0 ) {
40
+ self . set ( model . concat ( val ) )
40
41
}
41
- } else {
42
- model . $remove ( val )
42
+ } else if ( i > - 1 ) {
43
+ self . set ( model . slice ( 0 , i ) . concat ( model . slice ( i + 1 ) ) )
43
44
}
44
45
} else {
45
46
self . set ( getBooleanValue ( ) )
Original file line number Diff line number Diff line change @@ -185,11 +185,13 @@ describe('v-model', function () {
185
185
el . firstChild . click ( )
186
186
expect ( vm . list . length ) . toBe ( 2 )
187
187
expect ( vm . list [ 1 ] ) . toBe ( 1 )
188
- vm . list = [ vm . a ]
189
188
_ . 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
+ } )
193
195
} )
194
196
} )
195
197
You can’t perform that action at this time.
0 commit comments