fix(animations): check if target is present before removing its animation (#4586)

In Angular, if the NativeScriptAnimationModule is imported in another
NgModule more than once (which shouldn't be done), the renderer is instantiated twice. This
causes animation with empty targets to be created. If such animation is
removed, the app will crash. Additional check if the target is present
will prevent this.
This commit is contained in:
Stanimira Vlaeva
2017-07-25 10:28:09 +03:00
committed by Alexander Vakrilov
parent 1f9a64e908
commit 4bd3a94873

View File

@ -192,14 +192,20 @@ export class Animation extends AnimationBase {
this._propertyUpdateCallbacks.forEach(v => v());
this._disableHardwareAcceleration();
this._resolveAnimationFinishedPromise();
this._target._removeAnimation(this);
if (this._target) {
this._target._removeAnimation(this);
}
}
private _onAndroidAnimationCancel() { // tslint:disable-line
this._propertyResetCallbacks.forEach(v => v());
this._disableHardwareAcceleration();
this._rejectAnimationFinishedPromise();
this._target._removeAnimation(this);
if (this._target) {
this._target._removeAnimation(this);
}
}
private _createAnimators(propertyAnimation: PropertyAnimation): void {
@ -482,4 +488,4 @@ export class Animation extends AnimationBase {
}
}
}
}
}