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

Commit

Permalink
fix($animate): leave animation callback should not overridden by foll…
Browse files Browse the repository at this point in the history
…ow-up animation

Closes #12271
Closes #12249
Closes #12161
  • Loading branch information
sreeramu authored and matsko committed Aug 12, 2015
1 parent d33cedd commit 92e41ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ngAnimate/shared.js
Expand Up @@ -225,8 +225,16 @@ function mergeAnimationOptions(element, target, newOptions) {
delete newOptions.preparationClasses;
}

// noop is basically when there is no callback; otherwise something has been set
var realDomOperation = target.domOperation !== noop ? target.domOperation : null;

extend(target, newOptions);

// TODO(matsko or sreeramu): proper fix is to maintain all animation callback in array and call at last,but now only leave has the callback so no issue with this.
if (realDomOperation) {
target.domOperation = realDomOperation;
}

if (classes.addClass) {
target.addClass = classes.addClass;
} else {
Expand Down
18 changes: 18 additions & 0 deletions test/ngAnimate/animateSpec.js
Expand Up @@ -1775,5 +1775,23 @@ describe("animations", function() {
expect(count).toBe(1);
}));

it('leave: should remove the element even if another animation is called after',
inject(function($animate, $rootScope, $$rAF, $rootElement) {

var outerContainer = jqLite('<div></div>');
element = jqLite('<div></div>');
outerContainer.append(element);
$rootElement.append(outerContainer);

var runner = $animate.leave(element, $rootElement);
$animate.removeClass(element,'rclass');
$rootScope.$digest();
runner.end();
$$rAF.flush();

var isElementRemoved = !outerContainer[0].contains(element[0]);
expect(isElementRemoved).toBe(true);
}));

});
});

0 comments on commit 92e41ac

Please sign in to comment.