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 = {
3636 addClass ( this . el , value [ i ] )
3737 }
3838 }
39- this . prevKeys = value
39+ this . prevKeys = value . slice ( )
4040 } ,
4141
4242 cleanup : function ( value ) {
4343 if ( this . prevKeys ) {
4444 var i = this . prevKeys . length
4545 while ( i -- ) {
4646 var key = this . prevKeys [ i ]
47- if ( ! value || ! contains ( value , key ) ) {
47+ if ( key && ( ! value || ! contains ( value , key ) ) ) {
4848 removeClass ( this . el , key )
4949 }
5050 }
Original file line number Diff line number Diff line change @@ -47,8 +47,14 @@ if (_.inBrowser) {
4747 expect ( el . className ) . toBe ( 'a c d' )
4848 dir . update ( )
4949 expect ( el . className ) . toBe ( 'a' )
50- dir . update ( [ 'e' , '' ] )
50+ // test mutating array
51+ var arr = [ 'e' , '' ]
52+ dir . update ( arr )
5153 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' )
5258 } )
5359
5460 } )
You can’t perform that action at this time.
0 commit comments