diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 8357df8cb584..56601e28e956 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -1298,7 +1298,7 @@ angular.module('ngAnimate', ['ng']) parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter); parentID = parentCounter; } - return parentID + '-' + extractElementNode(element).className; + return parentID + '-' + extractElementNode(element).getAttribute('class'); } function animateSetup(animationEvent, element, className) { @@ -1364,7 +1364,7 @@ angular.module('ngAnimate', ['ng']) function animateRun(animationEvent, element, className, activeAnimationComplete) { var node = extractElementNode(element); var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY); - if(node.className.indexOf(className) == -1 || !elementData) { + if(node.getAttribute('class').indexOf(className) == -1 || !elementData) { activeAnimationComplete(); return; } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index b75a889ab611..822ba365484a 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -3730,5 +3730,42 @@ describe("ngAnimate", function() { expect(element.children().length).toBe(0); })); + + describe('SVG', function() { + it('should properly apply transitions on an SVG element', + inject(function($animate, $rootScope, $compile, $rootElement, $sniffer) { + + //jQuery doesn't handle SVG elements natively. Instead, an add-on library + //is required which is called jquery.svg.js. Therefore, when jQuery is + //active here there is no point to test this since it won't work by default. + if(!$sniffer.transitions || !_jqLiteMode) return; + + ss.addRule('circle.ng-enter', '-webkit-transition:1s linear all;' + + 'transition:1s linear all;'); + + var element = $compile('' + + '' + + '')($rootScope); + + $rootElement.append(element); + jqLite($document[0].body).append($rootElement); + + $rootScope.$digest(); + + $rootScope.on = true; + $rootScope.$digest(); + $animate.triggerReflow(); + + var child = element.find('circle'); + + expect(child.hasClass('ng-enter')).toBe(true); + expect(child.hasClass('ng-enter-active')).toBe(true); + + browserTrigger(child, 'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 1 }); + + expect(child.hasClass('ng-enter')).toBe(false); + expect(child.hasClass('ng-enter-active')).toBe(false); + })); + }); }); });