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

Commit 34d0740

Browse files
committed
fix($animate): ensure class-based animations always perform a domOperation if skipped
Closes #6957
1 parent 4d9efa2 commit 34d0740

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/ngAnimate/animate.js

+1
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ angular.module('ngAnimate', ['ng'])
849849
}
850850

851851
if(skipAnimation) {
852+
fireDOMOperation();
852853
fireBeforeCallbackAsync();
853854
fireAfterCallbackAsync();
854855
fireDoneCallbackAsync();

test/ngAnimate/animateSpec.js

+42
Original file line numberDiff line numberDiff line change
@@ -3014,6 +3014,48 @@ describe("ngAnimate", function() {
30143014
expect(element.hasClass('red')).toBe(true);
30153015
}));
30163016

3017+
it("should properly add and remove CSS classes when multiple classes are applied",
3018+
inject(function($compile, $rootScope, $animate) {
3019+
3020+
$animate.enabled();
3021+
3022+
var exp = "{{ className ? 'before ' + className + ' after' : '' }}";
3023+
var element = $compile('<div class="' + exp + '"></div>')($rootScope);
3024+
$rootElement.append(element);
3025+
jqLite($document[0].body).append($rootElement);
3026+
3027+
function assertClasses(str) {
3028+
var className = element.attr('class');
3029+
str.length == 0
3030+
? className.length == 0
3031+
: expect(className.split(/\s+/)).toEqual(str.split(' '));
3032+
}
3033+
3034+
$rootScope.className = '';
3035+
$rootScope.$digest();
3036+
$animate.triggerReflow();
3037+
3038+
assertClasses('');
3039+
3040+
$rootScope.className = 'one';
3041+
$rootScope.$digest();
3042+
$animate.triggerReflow();
3043+
3044+
assertClasses('before one after');
3045+
3046+
$rootScope.className = 'two';
3047+
$rootScope.$digest();
3048+
$animate.triggerReflow();
3049+
3050+
assertClasses('before after two');
3051+
3052+
$rootScope.className = '';
3053+
$rootScope.$digest();
3054+
//intentionally avoiding the triggerReflow operation
3055+
3056+
assertClasses('');
3057+
}));
3058+
30173059
it("should avoid mixing up substring classes during add and remove operations", function() {
30183060
var currentAnimation, currentFn;
30193061
module(function($animateProvider) {

0 commit comments

Comments
 (0)