File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ angular.module('ngAnimate', ['ng'])
494
494
495
495
var toAdd = [ ] , toRemove = [ ] ;
496
496
forEach ( map , function ( status , className ) {
497
- var hasClass = element . hasClass ( className ) ;
497
+ var hasClass = nodeHasClass ( element [ 0 ] , className ) ;
498
498
var matchingAnimation = lookup [ className ] || { } ;
499
499
500
500
// When addClass and removeClass is called then $animate will check to
@@ -1869,3 +1869,9 @@ angular.module('ngAnimate', ['ng'])
1869
1869
}
1870
1870
} ] ) ;
1871
1871
} ] ) ;
1872
+
1873
+ function nodeHasClass ( element , selector ) {
1874
+ if ( ! element . getAttribute ) return false ;
1875
+ return ( ( " " + ( element . getAttribute ( 'class' ) || '' ) + " " ) . replace ( / [ \n \t ] / g, " " ) .
1876
+ indexOf ( " " + selector + " " ) > - 1 ) ;
1877
+ }
Original file line number Diff line number Diff line change @@ -4641,6 +4641,18 @@ describe("ngAnimate", function() {
4641
4641
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
4642
4642
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
4643
4643
} ) ) ;
4644
+
4645
+
4646
+ it ( 'should properly remove classes from SVG elements' , inject ( function ( $animate , $rootScope ) {
4647
+ var element = jqLite ( '<svg width="500" height="500"><rect class="class-of-doom"></rect></svg>' ) ;
4648
+ var child = element . find ( 'rect' ) ;
4649
+ $animate . removeClass ( child , 'class-of-doom' ) ;
4650
+
4651
+ $rootScope . $digest ( ) ;
4652
+ expect ( child . attr ( 'class' ) ) . toBe ( '' ) ;
4653
+
4654
+ dealoc ( element ) ;
4655
+ } ) ) ;
4644
4656
} ) ;
4645
4657
} ) ;
4646
4658
} ) ;
You can’t perform that action at this time.
0 commit comments