File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 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) {
7878 updateClasses ( oldClasses , newClasses ) ;
7979 }
8080 }
81- oldVal = shallowCopy ( newVal ) ;
81+ if ( isArray ( newVal ) ) {
82+ oldVal = newVal . map ( function ( v ) { return shallowCopy ( v ) ; } ) ;
83+ } else {
84+ oldVal = shallowCopy ( newVal ) ;
85+ }
8286 }
8387 }
8488 } ;
Original file line number Diff line number Diff line change @@ -409,6 +409,22 @@ describe('ngClass', function() {
409409 expect ( e2 . hasClass ( 'even' ) ) . toBeTruthy ( ) ;
410410 expect ( e2 . hasClass ( 'odd' ) ) . toBeFalsy ( ) ;
411411 } ) ) ;
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+
412428} ) ;
413429
414430describe ( 'ngClass animations' , function ( ) {
You can’t perform that action at this time.
0 commit comments