Skip to content

Commit 9e6c753

Browse files
committed
fix($animate): ensure class-based animations are always skipped before structural digests are run
Closes angular#5582
1 parent 50bf029 commit 9e6c753

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/ngAnimate/animate.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,14 @@ angular.module('ngAnimate', ['ng'])
610610
}
611611

612612
var animations = [];
613+
613614
//only add animations if the currently running animation is not structural
614615
//or if there is no animation running at all
615-
if(!ngAnimateState.running || !(isClassBased && ngAnimateState.structural)) {
616+
var allowAnimations = isClassBased ?
617+
!ngAnimateState.disabled && (!ngAnimateState.running || !ngAnimateState.structural) :
618+
true;
619+
620+
if(allowAnimations) {
616621
forEach(matches, function(animation) {
617622
//add the animation to the queue to if it is allowed to be cancelled
618623
if(!animation.allowCancel || animation.allowCancel(element, animationEvent, className)) {

test/ngAnimate/animateSpec.js

+21
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,27 @@ describe("ngAnimate", function() {
538538
expect(completed).toBe(true);
539539
}));
540540

541+
it("should skip class-based animations if animations are directly disabled on the same element", function() {
542+
var capture;
543+
module(function($animateProvider) {
544+
$animateProvider.register('.capture', function() {
545+
return {
546+
addClass : function(element, className, done) {
547+
capture = true;
548+
done();
549+
}
550+
};
551+
});
552+
});
553+
inject(function($animate, $rootScope, $sniffer, $timeout) {
554+
$animate.enabled(true);
555+
$animate.enabled(false, element);
556+
557+
$animate.addClass(element, 'capture');
558+
expect(element.hasClass('capture')).toBe(true);
559+
expect(capture).not.toBe(true);
560+
});
561+
});
541562

542563
it("should fire the cancel/end function with the correct flag in the parameters",
543564
inject(function($animate, $rootScope, $sniffer, $timeout) {

0 commit comments

Comments
 (0)