From a606888724cd63f33c68886581ab7cd386be8809 Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Tue, 2 Sep 2014 18:04:19 -0400 Subject: [PATCH] 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 --- src/AngularPublic.js | 3 ++- src/ngAnimate/animate.js | 2 +- test/ngAnimate/animateSpec.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/AngularPublic.js b/src/AngularPublic.js index c263e1a9c8cf..aaa4bb0376ac 100644 --- a/src/AngularPublic.js +++ b/src/AngularPublic.js @@ -140,7 +140,8 @@ function publishExternalAPI(angular){ 'getTestability': getTestability, '$$minErr': minErr, '$$csp': csp, - 'reloadWithDebugInfo': reloadWithDebugInfo + 'reloadWithDebugInfo': reloadWithDebugInfo, + '$$hasClass': jqLiteHasClass }); angularModule = setupModuleLoader(window); diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index cccb5d875ef8..e66fcd6e1cfc 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -494,7 +494,7 @@ angular.module('ngAnimate', ['ng']) var toAdd = [], toRemove = []; forEach(map, function(status, className) { - var hasClass = element.hasClass(className); + var hasClass = angular.$$hasClass(element[0], className); var matchingAnimation = lookup[className] || {}; // When addClass and removeClass is called then $animate will check to diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index ef1e0fecab0b..e6e71845eb97 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -4641,6 +4641,18 @@ describe("ngAnimate", function() { expect(child.hasClass('ng-enter')).toBe(false); expect(child.hasClass('ng-enter-active')).toBe(false); })); + + + it('should properly remove classes from SVG elements', inject(function($animate, $rootScope) { + var element = jqLite(''); + var child = element.find('rect'); + $animate.removeClass(child, 'class-of-doom'); + + $rootScope.$digest(); + expect(child.attr('class')).toBe(''); + + dealoc(element); + })); }); }); });