From 42fd1dc13f41cba6f31710c044d4daf369e3b832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Mon, 11 May 2015 12:03:49 -0700 Subject: [PATCH] fix(ngAnimate): ensure anchored animations remove the leave element at correct time Due to a mismatch of where the `options.domOperation` value was stored, the element involved in the `leave` animation for an anchored animation session was not removed as soon as the leave animation ended. This resulted in a pending element persisting within the DOM until all animations involved in the associated anchor animation were complete. This patch fixes this issue. Closes #11850 --- src/ngAnimate/animateCssDriver.js | 8 +++++--- test/ngAnimate/animateCssDriverSpec.js | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ngAnimate/animateCssDriver.js b/src/ngAnimate/animateCssDriver.js index 5cbaa1a041c4..c358130b814f 100644 --- a/src/ngAnimate/animateCssDriver.js +++ b/src/ngAnimate/animateCssDriver.js @@ -234,10 +234,12 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro // we special case the leave animation since we want to ensure that // the element is removed as soon as the animation is over. Otherwise - // a flicker might appear or the element may not be removed at all + // a flicker might appear or the element may not be removed until all + // the other animations have completed themselves (which would then + // leave a pending element in the background). options.event = animationDetails.event; - if (options.event === 'leave' && animationDetails.domOperation) { - options.onDone = animationDetails.domOperation; + if (options.event === 'leave') { + options.onDone = options.domOperation; } var animator = $animateCss(element, options); diff --git a/test/ngAnimate/animateCssDriverSpec.js b/test/ngAnimate/animateCssDriverSpec.js index bf0eec8bce7f..46b0b780c57a 100644 --- a/test/ngAnimate/animateCssDriverSpec.js +++ b/test/ngAnimate/animateCssDriverSpec.js @@ -908,10 +908,12 @@ describe("ngAnimate $$animateCssDriver", function() { inject(function($rootElement, $$rAF) { toAnimation.event = 'enter'; + toAnimation.options = {}; fromAnimation.event = 'leave'; + fromAnimation.options = {}; var leaveOp = function() { }; - fromAnimation.domOperation = leaveOp; + fromAnimation.options.domOperation = leaveOp; driver({ from: fromAnimation,