Skip to content

Commit b36f4bc

Browse files
matskochuckjaz
authored andcommitted
fix(animations): allow players to be destroyed before initialized (#13346)
Closes #13293 Closes #13346
1 parent 355c537 commit b36f4bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

modules/@angular/platform-browser/src/dom/web_animations_player.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ export class WebAnimationsPlayer implements AnimationPlayer {
124124
this._started = false;
125125
}
126126

127-
private _resetDomPlayerState() { this._player.cancel(); }
127+
private _resetDomPlayerState() {
128+
if (this._player) {
129+
this._player.cancel();
130+
}
131+
}
128132

129133
restart(): void {
130134
this.reset();

modules/@angular/platform-browser/test/dom/web_animations_player_spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ export function main() {
175175
expect(data['keyframes']).toEqual([{opacity: '0.5'}, {opacity: '1'}]);
176176
});
177177

178+
it('should allow the player to be destroyed before it is initialized', () => {
179+
const elm = el('<div></div>');
180+
const player = new ExtendedWebAnimationsPlayer(elm, [], {});
181+
expect(() => { player.destroy(); }).not.toThrowError();
182+
});
183+
178184
describe('previousStyle', () => {
179185
it('should merge keyframe styles based on the previous styles passed in when the player has finished its operation',
180186
() => {

0 commit comments

Comments
 (0)