@@ -3014,6 +3014,48 @@ describe("ngAnimate", function() {
3014
3014
expect ( element . hasClass ( 'red' ) ) . toBe ( true ) ;
3015
3015
} ) ) ;
3016
3016
3017
+ it ( "should properly add and remove CSS classes when multiple classes are applied" ,
3018
+ inject ( function ( $compile , $rootScope , $animate ) {
3019
+
3020
+ $animate . enabled ( ) ;
3021
+
3022
+ var exp = "{{ className ? 'before ' + className + ' after' : '' }}" ;
3023
+ var element = $compile ( '<div class="' + exp + '"></div>' ) ( $rootScope ) ;
3024
+ $rootElement . append ( element ) ;
3025
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
3026
+
3027
+ function assertClasses ( str ) {
3028
+ var className = element . attr ( 'class' ) ;
3029
+ str . length == 0
3030
+ ? className . length == 0
3031
+ : expect ( className . split ( / \s + / ) ) . toEqual ( str . split ( ' ' ) ) ;
3032
+ }
3033
+
3034
+ $rootScope . className = '' ;
3035
+ $rootScope . $digest ( ) ;
3036
+ $animate . triggerReflow ( ) ;
3037
+
3038
+ assertClasses ( '' ) ;
3039
+
3040
+ $rootScope . className = 'one' ;
3041
+ $rootScope . $digest ( ) ;
3042
+ $animate . triggerReflow ( ) ;
3043
+
3044
+ assertClasses ( 'before one after' ) ;
3045
+
3046
+ $rootScope . className = 'two' ;
3047
+ $rootScope . $digest ( ) ;
3048
+ $animate . triggerReflow ( ) ;
3049
+
3050
+ assertClasses ( 'before after two' ) ;
3051
+
3052
+ $rootScope . className = '' ;
3053
+ $rootScope . $digest ( ) ;
3054
+ //intentionally avoiding the triggerReflow operation
3055
+
3056
+ assertClasses ( '' ) ;
3057
+ } ) ) ;
3058
+
3017
3059
it ( "should avoid mixing up substring classes during add and remove operations" , function ( ) {
3018
3060
var currentAnimation , currentFn ;
3019
3061
module ( function ( $animateProvider ) {
0 commit comments