fix(animations): allow players to be destroyed before initialized (#13346)

Closes #13293
Closes #13346
This commit is contained in:
Matias Niemelä 2016-12-15 14:18:57 -08:00 committed by Chuck Jazdzewski
parent 5b6e8ea3ec
commit 0c19898694
2 changed files with 11 additions and 1 deletions

View File

@ -124,7 +124,11 @@ export class WebAnimationsPlayer implements AnimationPlayer {
this._started = false; this._started = false;
} }
private _resetDomPlayerState() { this._player.cancel(); } private _resetDomPlayerState() {
if (this._player) {
this._player.cancel();
}
}
restart(): void { restart(): void {
this.reset(); this.reset();

View File

@ -175,6 +175,12 @@ export function main() {
expect(data['keyframes']).toEqual([{opacity: '0.5'}, {opacity: '1'}]); expect(data['keyframes']).toEqual([{opacity: '0.5'}, {opacity: '1'}]);
}); });
it('should allow the player to be destroyed before it is initialized', () => {
const elm = el('<div></div>');
const player = new ExtendedWebAnimationsPlayer(elm, [], {});
expect(() => { player.destroy(); }).not.toThrowError();
});
describe('previousStyle', () => { describe('previousStyle', () => {
it('should merge keyframe styles based on the previous styles passed in when the player has finished its operation', it('should merge keyframe styles based on the previous styles passed in when the player has finished its operation',
() => { () => {