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

Commit a41a2a1

Browse files
Tomer Chachamumatsko
Tomer Chachamu
authored andcommitted
fix(ngAnimate): setting classNameFilter disables animation inside ng-if
Closes #6539
1 parent eadd8d0 commit a41a2a1

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

src/ngAnimate/animate.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ angular.module('ngAnimate', ['ng'])
770770
fireDOMOperation();
771771
fireBeforeCallbackAsync();
772772
fireAfterCallbackAsync();
773-
fireDoneCallbackAsync();
773+
closeAnimation();
774774
return;
775775
}
776776

@@ -949,7 +949,7 @@ angular.module('ngAnimate', ['ng'])
949949
animation, but class-based animations don't. An example of this
950950
failing would be when a parent HTML tag has a ng-class attribute
951951
causing ALL directives below to skip animations during the digest */
952-
if(runner.isClassBased) {
952+
if(runner && runner.isClassBased) {
953953
cleanup(element, className);
954954
} else {
955955
$$asyncCallback(function() {

test/ngAnimate/animateSpec.js

+43
Original file line numberDiff line numberDiff line change
@@ -3356,6 +3356,49 @@ describe("ngAnimate", function() {
33563356
});
33573357
});
33583358

3359+
it('should animate only the specified CSS className inside ng-if', function() {
3360+
var captures = {};
3361+
module(function($animateProvider) {
3362+
$animateProvider.classNameFilter(/prefixed-animation/);
3363+
$animateProvider.register('.capture', function() {
3364+
return {
3365+
enter : buildFn('enter'),
3366+
leave : buildFn('leave')
3367+
};
3368+
3369+
function buildFn(key) {
3370+
return function(element, className, done) {
3371+
captures[key] = true;
3372+
(done || className)();
3373+
}
3374+
}
3375+
});
3376+
});
3377+
inject(function($rootScope, $compile, $rootElement, $document, $sniffer, $animate) {
3378+
if(!$sniffer.transitions) return;
3379+
3380+
var upperElement = $compile('<div><div ng-if=1><span class="capture prefixed-animation"></span></div></div>')($rootScope);
3381+
$rootElement.append(upperElement);
3382+
jqLite($document[0].body).append($rootElement);
3383+
3384+
$rootScope.$digest();
3385+
$animate.triggerCallbacks();
3386+
3387+
var element = upperElement.find('span');
3388+
3389+
var leaveDone = false;
3390+
$animate.leave(element, function() {
3391+
leaveDone = true;
3392+
});
3393+
3394+
$rootScope.$digest();
3395+
$animate.triggerCallbacks();
3396+
3397+
expect(captures['leave']).toBe(true);
3398+
expect(leaveDone).toBe(true);
3399+
});
3400+
});
3401+
33593402
it('should respect the most relevant CSS transition property if defined in multiple classes',
33603403
inject(function($sniffer, $compile, $rootScope, $rootElement, $animate, $timeout) {
33613404

0 commit comments

Comments
 (0)