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

Commit

Permalink
fix($animate): ensure class-based animations always perform a domOper…
Browse files Browse the repository at this point in the history
…ation if skipped

Closes #6957
  • Loading branch information
matsko committed Apr 4, 2014
1 parent dbe381f commit 708f2ba
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ angular.module('ngAnimate', ['ng'])
}

if(skipAnimation) {
fireDOMOperation();
fireBeforeCallbackAsync();
fireAfterCallbackAsync();
fireDoneCallbackAsync();
Expand Down
42 changes: 42 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3088,6 +3088,48 @@ describe("ngAnimate", function() {
expect(element.hasClass('red')).toBe(true);
}));

it("should properly add and remove CSS classes when multiple classes are applied",
inject(function($compile, $rootScope, $animate) {

$animate.enabled();

var exp = "{{ className ? 'before ' + className + ' after' : '' }}";
var element = $compile('<div class="' + exp + '"></div>')($rootScope);
$rootElement.append(element);
jqLite($document[0].body).append($rootElement);

function assertClasses(str) {
var className = element.attr('class');
str.length == 0
? className.length == 0
: expect(className.split(/\s+/)).toEqual(str.split(' '));
}

$rootScope.className = '';
$rootScope.$digest();
$animate.triggerReflow();

assertClasses('');

$rootScope.className = 'one';
$rootScope.$digest();
$animate.triggerReflow();

assertClasses('before one after');

$rootScope.className = 'two';
$rootScope.$digest();
$animate.triggerReflow();

assertClasses('before after two');

$rootScope.className = '';
$rootScope.$digest();
//intentionally avoiding the triggerReflow operation

assertClasses('');
}));

it("should avoid mixing up substring classes during add and remove operations", function() {
var currentAnimation, currentFn;
module(function($animateProvider) {
Expand Down

0 comments on commit 708f2ba

Please sign in to comment.