File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
test/unit/specs/directives/internal Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -36,15 +36,15 @@ module.exports = {
36
36
addClass ( this . el , value [ i ] )
37
37
}
38
38
}
39
- this . prevKeys = value
39
+ this . prevKeys = value . slice ( )
40
40
} ,
41
41
42
42
cleanup : function ( value ) {
43
43
if ( this . prevKeys ) {
44
44
var i = this . prevKeys . length
45
45
while ( i -- ) {
46
46
var key = this . prevKeys [ i ]
47
- if ( ! value || ! contains ( value , key ) ) {
47
+ if ( key && ( ! value || ! contains ( value , key ) ) ) {
48
48
removeClass ( this . el , key )
49
49
}
50
50
}
Original file line number Diff line number Diff line change @@ -47,8 +47,14 @@ if (_.inBrowser) {
47
47
expect ( el . className ) . toBe ( 'a c d' )
48
48
dir . update ( )
49
49
expect ( el . className ) . toBe ( 'a' )
50
- dir . update ( [ 'e' , '' ] )
50
+ // test mutating array
51
+ var arr = [ 'e' , '' ]
52
+ dir . update ( arr )
51
53
expect ( el . className ) . toBe ( 'a e' )
54
+ arr . length = 0
55
+ arr . push ( 'f' )
56
+ dir . update ( arr )
57
+ expect ( el . className ) . toBe ( 'a f' )
52
58
} )
53
59
54
60
} )
You can’t perform that action at this time.
0 commit comments