Skip to content

Commit 98efe31

Browse files
committed
address comments
1 parent 57e2cd2 commit 98efe31

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ describe('CdkAriaLive', () => {
128128
providers: [{
129129
provide: MutationObserverFactory,
130130
useValue: {
131-
create: function(callback: Function) {
131+
create: (callback: Function) => {
132132
mutationCallbacks.push(callback);
133133

134134
return {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class LiveAnnouncer implements OnDestroy {
9595
selector: '[cdkAriaLive]'
9696
})
9797
export class CdkAriaLive implements OnDestroy {
98+
/** The aria-live politeness level to use when announcing messages. */
9899
@Input('cdkAriaLive')
99100
get politeness(): AriaLivePoliteness { return this._politeness; }
100101
set politeness(value: AriaLivePoliteness) {
@@ -105,10 +106,12 @@ export class CdkAriaLive implements OnDestroy {
105106
this._subscription = null;
106107
}
107108
} else {
108-
this._subscription = this._ngZone.runOutsideAngular(
109-
() => this._contentObserver.observe(this._elementRef.nativeElement).subscribe(
110-
() => this._liveAnnouncer.announce(
111-
this._elementRef.nativeElement.innerText, this._politeness)));
109+
if (!this._subscription) {
110+
this._subscription = this._ngZone.runOutsideAngular(
111+
() => this._contentObserver.observe(this._elementRef.nativeElement).subscribe(
112+
() => this._liveAnnouncer.announce(
113+
this._elementRef.nativeElement.innerText, this._politeness)));
114+
}
112115
}
113116
}
114117
private _politeness: AriaLivePoliteness = 'off';

0 commit comments

Comments
 (0)