fix(core): trigger host animations for elements that are removed. (#15251)

Fixes #14813
Fixes #15193
This commit is contained in:
Tobias Bosch
2017-03-17 11:04:30 -07:00
committed by Miško Hevery
parent 28ce68a13d
commit 0d3e314df0
5 changed files with 33 additions and 14 deletions

View File

@ -90,7 +90,15 @@ export class AnimationRenderer implements Renderer2 {
}
removeChild(parent: any, oldChild: any): void {
this._engine.onRemove(oldChild, () => this.delegate.removeChild(parent, oldChild));
this._engine.onRemove(oldChild, () => {
// Note: if an component element has a leave animation, and the component
// a host leave animation, the view engine will call `removeChild` for the parent
// component renderer as well as for the child component renderer.
// Therefore, we need to check if we already removed the element.
if (this.delegate.parentNode(oldChild)) {
this.delegate.removeChild(parent, oldChild);
}
});
this._queueFlush();
}