Skip to content

Commit

Permalink
fix(ngAnimate): setting classNameFilter disables animation inside ng-if
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomer Chachamu committed Mar 4, 2014
1 parent d07101d commit 45a7ef1
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 @@ -771,7 +771,7 @@ angular.module('ngAnimate', ['ng'])
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
fireDoneCallbackAsync();
closeAnimation();
return;
}

Expand Down Expand Up @@ -950,7 +950,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, $timeout, $templateCache, $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 45a7ef1

Please sign in to comment.