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

Commit

Permalink
fix(ngAnimate): setting classNameFilter disables animation inside ng-if
Browse files Browse the repository at this point in the history
Closes #6539
  • Loading branch information
Tomer Chachamu authored and matsko committed Mar 14, 2014
1 parent 3cc02e7 commit 129e2e0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ angular.module('ngAnimate', ['ng'])
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
fireDoneCallbackAsync();
closeAnimation();
return;
}

Expand Down Expand Up @@ -949,7 +949,7 @@ angular.module('ngAnimate', ['ng'])
animation, but class-based animations don't. An example of this
failing would be when a parent HTML tag has a ng-class attribute
causing ALL directives below to skip animations during the digest */
if(runner.isClassBased) {
if(runner && runner.isClassBased) {
cleanup(element, className);
} else {
$$asyncCallback(function() {
Expand Down
43 changes: 43 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3356,6 +3356,49 @@ describe("ngAnimate", function() {
});
});

it('should animate only the specified CSS className inside ng-if', function() {
var captures = {};
module(function($animateProvider) {
$animateProvider.classNameFilter(/prefixed-animation/);
$animateProvider.register('.capture', function() {
return {
enter : buildFn('enter'),
leave : buildFn('leave')
};

function buildFn(key) {
return function(element, className, done) {
captures[key] = true;
(done || className)();
}
}
});
});
inject(function($rootScope, $compile, $rootElement, $document, $sniffer, $animate) {
if(!$sniffer.transitions) return;

var upperElement = $compile('<div><div ng-if=1><span class="capture prefixed-animation"></span></div></div>')($rootScope);
$rootElement.append(upperElement);
jqLite($document[0].body).append($rootElement);

$rootScope.$digest();
$animate.triggerCallbacks();

var element = upperElement.find('span');

var leaveDone = false;
$animate.leave(element, function() {
leaveDone = true;
});

$rootScope.$digest();
$animate.triggerCallbacks();

expect(captures['leave']).toBe(true);
expect(leaveDone).toBe(true);
});
});

it('should respect the most relevant CSS transition property if defined in multiple classes',
inject(function($sniffer, $compile, $rootScope, $rootElement, $animate, $timeout) {

Expand Down

0 comments on commit 129e2e0

Please sign in to comment.