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

Commit 81bf7ed

Browse files
sreeramuNarretz
authored andcommitted
fix(ngAnimate) : make svg elements work with classNameFilter
(#14529) Closes #14508
1 parent d7274f0 commit 81bf7ed

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/ngAnimate/animateCss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
892892
$$jqLite.addClass(element, activeClasses);
893893

894894
if (flags.recalculateTimingStyles) {
895-
fullClassName = node.className + ' ' + preparationClasses;
895+
fullClassName = node.getAttribute('class') + ' ' + preparationClasses;
896896
cacheKey = gcsHashFn(node, fullClassName);
897897

898898
timings = computeTimings(node, fullClassName, cacheKey);

src/ngAnimate/animateQueue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
361361
return runner;
362362
}
363363

364-
var className = [node.className, options.addClass, options.removeClass].join(' ');
364+
var className = [node.getAttribute('class'), options.addClass, options.removeClass].join(' ');
365365
if (!isAnimatableClassName(className)) {
366366
close();
367367
return runner;

test/ngAnimate/animateSpec.js

+21-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ describe("animations", function() {
179179
});
180180
});
181181

182-
it('should animate only the specified CSS className matched within $animateProvider.classNameFilter', function() {
182+
it('should animate only the specified CSS className matched within $animateProvider.classNameFilter for div', function() {
183183
module(function($animateProvider) {
184184
$animateProvider.classNameFilter(/only-allow-this-animation/);
185185
});
@@ -198,6 +198,26 @@ describe("animations", function() {
198198
});
199199
});
200200

201+
it('should animate only the specified CSS className matched within $animateProvider.classNameFilter for svg', function() {
202+
module(function($animateProvider) {
203+
$animateProvider.classNameFilter(/only-allow-this-animation-svg/);
204+
});
205+
inject(function($animate, $rootScope, $compile) {
206+
var svgElement = $compile('<svg class="element"></svg>')($rootScope);
207+
expect(svgElement).not.toHaveClass('only-allow-this-animation-svg');
208+
209+
$animate.enter(svgElement, parent);
210+
$rootScope.$digest();
211+
expect(capturedAnimation).toBeFalsy();
212+
213+
svgElement.attr('class', 'element only-allow-this-animation-svg');
214+
215+
$animate.leave(svgElement, parent);
216+
$rootScope.$digest();
217+
expect(capturedAnimation).toBeTruthy();
218+
});
219+
});
220+
201221
they('should not apply the provided options.$prop value unless it\'s a string or string-based array', ['addClass', 'removeClass'], function(prop) {
202222
inject(function($animate, $rootScope) {
203223
var startingCssClasses = element.attr('class') || '';

0 commit comments

Comments
 (0)