@@ -3088,6 +3088,48 @@ describe("ngAnimate", function() {
3088
3088
expect ( element . hasClass ( 'red' ) ) . toBe ( true ) ;
3089
3089
} ) ) ;
3090
3090
3091
+ it ( "should properly add and remove CSS classes when multiple classes are applied" ,
3092
+ inject ( function ( $compile , $rootScope , $animate ) {
3093
+
3094
+ $animate . enabled ( ) ;
3095
+
3096
+ var exp = "{{ className ? 'before ' + className + ' after' : '' }}" ;
3097
+ var element = $compile ( '<div class="' + exp + '"></div>' ) ( $rootScope ) ;
3098
+ $rootElement . append ( element ) ;
3099
+ jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
3100
+
3101
+ function assertClasses ( str ) {
3102
+ var className = element . attr ( 'class' ) ;
3103
+ str . length == 0
3104
+ ? className . length == 0
3105
+ : expect ( className . split ( / \s + / ) ) . toEqual ( str . split ( ' ' ) ) ;
3106
+ }
3107
+
3108
+ $rootScope . className = '' ;
3109
+ $rootScope . $digest ( ) ;
3110
+ $animate . triggerReflow ( ) ;
3111
+
3112
+ assertClasses ( '' ) ;
3113
+
3114
+ $rootScope . className = 'one' ;
3115
+ $rootScope . $digest ( ) ;
3116
+ $animate . triggerReflow ( ) ;
3117
+
3118
+ assertClasses ( 'before one after' ) ;
3119
+
3120
+ $rootScope . className = 'two' ;
3121
+ $rootScope . $digest ( ) ;
3122
+ $animate . triggerReflow ( ) ;
3123
+
3124
+ assertClasses ( 'before after two' ) ;
3125
+
3126
+ $rootScope . className = '' ;
3127
+ $rootScope . $digest ( ) ;
3128
+ //intentionally avoiding the triggerReflow operation
3129
+
3130
+ assertClasses ( '' ) ;
3131
+ } ) ) ;
3132
+
3091
3133
it ( "should avoid mixing up substring classes during add and remove operations" , function ( ) {
3092
3134
var currentAnimation , currentFn ;
3093
3135
module ( function ( $animateProvider ) {
0 commit comments