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

Commit 92e41ac

Browse files
sreeramumatsko
authored andcommitted
fix($animate): leave animation callback should not overridden by follow-up animation
Closes #12271 Closes #12249 Closes #12161
1 parent d33cedd commit 92e41ac

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/ngAnimate/shared.js

+8
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,16 @@ function mergeAnimationOptions(element, target, newOptions) {
225225
delete newOptions.preparationClasses;
226226
}
227227

228+
// noop is basically when there is no callback; otherwise something has been set
229+
var realDomOperation = target.domOperation !== noop ? target.domOperation : null;
230+
228231
extend(target, newOptions);
229232

233+
// 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.
234+
if (realDomOperation) {
235+
target.domOperation = realDomOperation;
236+
}
237+
230238
if (classes.addClass) {
231239
target.addClass = classes.addClass;
232240
} else {

test/ngAnimate/animateSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -1775,5 +1775,23 @@ describe("animations", function() {
17751775
expect(count).toBe(1);
17761776
}));
17771777

1778+
it('leave: should remove the element even if another animation is called after',
1779+
inject(function($animate, $rootScope, $$rAF, $rootElement) {
1780+
1781+
var outerContainer = jqLite('<div></div>');
1782+
element = jqLite('<div></div>');
1783+
outerContainer.append(element);
1784+
$rootElement.append(outerContainer);
1785+
1786+
var runner = $animate.leave(element, $rootElement);
1787+
$animate.removeClass(element,'rclass');
1788+
$rootScope.$digest();
1789+
runner.end();
1790+
$$rAF.flush();
1791+
1792+
var isElementRemoved = !outerContainer[0].contains(element[0]);
1793+
expect(isElementRemoved).toBe(true);
1794+
}));
1795+
17781796
});
17791797
});

0 commit comments

Comments
 (0)