This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,11 @@ function classDirective(name, selector) {
78
78
updateClasses ( oldClasses , newClasses ) ;
79
79
}
80
80
}
81
- oldVal = shallowCopy ( newVal ) ;
81
+ if ( isArray ( newVal ) ) {
82
+ oldVal = newVal . map ( function ( v ) { return shallowCopy ( v ) ; } ) ;
83
+ } else {
84
+ oldVal = shallowCopy ( newVal ) ;
85
+ }
82
86
}
83
87
}
84
88
} ;
Original file line number Diff line number Diff line change @@ -409,6 +409,22 @@ describe('ngClass', function() {
409
409
expect ( e2 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
410
410
expect ( e2 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
411
411
} ) ) ;
412
+
413
+ it ( 'should support mixed array/object variable with a mutating object' ,
414
+ inject ( function ( $rootScope , $compile ) {
415
+ element = $compile ( '<div ng-class="classVar"></div>' ) ( $rootScope ) ;
416
+
417
+ $rootScope . classVar = [ { orange : true } ] ;
418
+ $rootScope . $digest ( ) ;
419
+ expect ( element ) . toHaveClass ( 'orange' ) ;
420
+
421
+ $rootScope . classVar [ 0 ] . orange = false ;
422
+ $rootScope . $digest ( ) ;
423
+
424
+ expect ( element ) . not . toHaveClass ( 'orange' ) ;
425
+ } )
426
+ ) ;
427
+
412
428
} ) ;
413
429
414
430
describe ( 'ngClass animations' , function ( ) {
You can’t perform that action at this time.
0 commit comments