File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -57,15 +57,15 @@ module.exports = {
57
57
addClass ( this . el , value [ i ] )
58
58
}
59
59
}
60
- this . prevKeys = value
60
+ this . prevKeys = value . slice ( )
61
61
} ,
62
62
63
63
cleanup : function ( value ) {
64
64
if ( this . prevKeys ) {
65
65
var i = this . prevKeys . length
66
66
while ( i -- ) {
67
67
var key = this . prevKeys [ i ]
68
- if ( ! value || ! contains ( value , key ) ) {
68
+ if ( key && ( ! value || ! contains ( value , key ) ) ) {
69
69
removeClass ( this . el , key )
70
70
}
71
71
}
Original file line number Diff line number Diff line change @@ -59,8 +59,14 @@ if (_.inBrowser) {
59
59
expect ( el . className ) . toBe ( 'a c d' )
60
60
dir . update ( )
61
61
expect ( el . className ) . toBe ( 'a' )
62
- dir . update ( [ 'e' , '' ] )
62
+ // test mutating array
63
+ var arr = [ 'e' , '' ]
64
+ dir . update ( arr )
63
65
expect ( el . className ) . toBe ( 'a e' )
66
+ arr . length = 0
67
+ arr . push ( 'f' )
68
+ dir . update ( arr )
69
+ expect ( el . className ) . toBe ( 'a f' )
64
70
} )
65
71
66
72
} )
You can’t perform that action at this time.
0 commit comments