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

Commit 708f2ba

Browse files
committed
fix($animate): ensure class-based animations always perform a domOperation if skipped
Closes #6957
1 parent dbe381f commit 708f2ba

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
@@ -934,6 +934,7 @@ angular.module('ngAnimate', ['ng'])
934934
}
935935

936936
if(skipAnimation) {
937+
fireDOMOperation();
937938
fireBeforeCallbackAsync();
938939
fireAfterCallbackAsync();
939940
fireDoneCallbackAsync();

test/ngAnimate/animateSpec.js

+42
Original file line numberDiff line numberDiff line change
@@ -3088,6 +3088,48 @@ describe("ngAnimate", function() {
30883088
expect(element.hasClass('red')).toBe(true);
30893089
}));
30903090

3091+
it("should properly add and remove CSS classes when multiple classes are applied",
3092+
inject(function($compile, $rootScope, $animate) {
3093+
3094+
$animate.enabled();
3095+
3096+
var exp = "{{ className ? 'before ' + className + ' after' : '' }}";
3097+
var element = $compile('<div class="' + exp + '"></div>')($rootScope);
3098+
$rootElement.append(element);
3099+
jqLite($document[0].body).append($rootElement);
3100+
3101+
function assertClasses(str) {
3102+
var className = element.attr('class');
3103+
str.length == 0
3104+
? className.length == 0
3105+
: expect(className.split(/\s+/)).toEqual(str.split(' '));
3106+
}
3107+
3108+
$rootScope.className = '';
3109+
$rootScope.$digest();
3110+
$animate.triggerReflow();
3111+
3112+
assertClasses('');
3113+
3114+
$rootScope.className = 'one';
3115+
$rootScope.$digest();
3116+
$animate.triggerReflow();
3117+
3118+
assertClasses('before one after');
3119+
3120+
$rootScope.className = 'two';
3121+
$rootScope.$digest();
3122+
$animate.triggerReflow();
3123+
3124+
assertClasses('before after two');
3125+
3126+
$rootScope.className = '';
3127+
$rootScope.$digest();
3128+
//intentionally avoiding the triggerReflow operation
3129+
3130+
assertClasses('');
3131+
}));
3132+
30913133
it("should avoid mixing up substring classes during add and remove operations", function() {
30923134
var currentAnimation, currentFn;
30933135
module(function($animateProvider) {

0 commit comments

Comments
 (0)