Skip to content

Commit 3b45502

Browse files
atscottmmalerba
authored andcommitted
refactor(cdk/a11y): only call currentResolve if defined (#28701)
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. (cherry picked from commit b13818a)
1 parent 4e0e120 commit 3b45502

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/cdk/a11y/live-announcer/live-announcer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export class LiveAnnouncer implements OnDestroy {
135135
this._previousTimeout = setTimeout(() => this.clear(), duration);
136136
}
137137

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

0 commit comments

Comments
 (0)