Skip to content

Commit

Permalink
refactor(cdk/a11y): only call currentResolve if defined (#28701)
Browse files Browse the repository at this point in the history
Should it be possible for it to be undefined within the timeout body?
No. But ZoneJS and test environments do weird things so it's better to
be safe.
  • Loading branch information
atscott authored Mar 11, 2024
1 parent 1f8fa3e commit b13818a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cdk/a11y/live-announcer/live-announcer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export class LiveAnnouncer implements OnDestroy {
this._previousTimeout = setTimeout(() => this.clear(), duration);
}

this._currentResolve!();
// For some reason in tests this can be undefined
// Probably related to ZoneJS and every other thing that patches browser APIs in tests
this._currentResolve?.();
this._currentPromise = this._currentResolve = undefined;
}, 100);

Expand Down

0 comments on commit b13818a

Please sign in to comment.