Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a606888

Browse files
committed
fix(ngAnimate): support removing classes from SVG elements when using jQuery
Without this CL, ngShowHide will not work without the use of monkeypatched fixes for jQuery such as https://github.com/kbwood/svg 's jquery-svgdom.js script. Closes #8872
1 parent b01a03c commit a606888

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/AngularPublic.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ function publishExternalAPI(angular){
140140
'getTestability': getTestability,
141141
'$$minErr': minErr,
142142
'$$csp': csp,
143-
'reloadWithDebugInfo': reloadWithDebugInfo
143+
'reloadWithDebugInfo': reloadWithDebugInfo,
144+
'$$hasClass': jqLiteHasClass
144145
});
145146

146147
angularModule = setupModuleLoader(window);

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ angular.module('ngAnimate', ['ng'])
494494

495495
var toAdd = [], toRemove = [];
496496
forEach(map, function(status, className) {
497-
var hasClass = element.hasClass(className);
497+
var hasClass = angular.$$hasClass(element[0], className);
498498
var matchingAnimation = lookup[className] || {};
499499

500500
// When addClass and removeClass is called then $animate will check to

test/ngAnimate/animateSpec.js

+12
Original file line numberDiff line numberDiff line change
@@ -4641,6 +4641,18 @@ describe("ngAnimate", function() {
46414641
expect(child.hasClass('ng-enter')).toBe(false);
46424642
expect(child.hasClass('ng-enter-active')).toBe(false);
46434643
}));
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+
}));
46444656
});
46454657
});
46464658
});

0 commit comments

Comments
 (0)