Skip to content

Commit aa826e9

Browse files
crisbetommalerba
authored andcommitted
refactor(a11y): remove deprecated APIs for 9.0.0 (#17385)
Cleans up the deprecated APIs for v9 from the `cdk/a11y` package. BREAKING CHANGES: * `ListKeyManager.updateActiveItemIndex` has been removed. Use `ListKeyManager.updateActiveItem` instead. * `ARIA_DESCRIBER_PROVIDER_FACTORY` has been removed. * `ARIA_DESCRIBER_PROVIDER` has been removed. * `FOCUS_MONITOR_PROVIDER_FACTORY` has been removed. * `FOCUS_MONITOR_PROVIDER` has been removed. * `LIVE_ANNOUNCER_PROVIDER_FACTORY` has been removed. * `LIVE_ANNOUNCER_PROVIDER` has been removed.
1 parent ef8ba0d commit aa826e9

File tree

11 files changed

+8
-102
lines changed

11 files changed

+8
-102
lines changed

src/cdk/a11y/aria-describer/aria-describer.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
*/
88

99
import {DOCUMENT} from '@angular/common';
10-
import {
11-
Inject,
12-
Injectable,
13-
InjectionToken,
14-
OnDestroy,
15-
Optional,
16-
SkipSelf,
17-
} from '@angular/core';
10+
import {Inject, Injectable, OnDestroy} from '@angular/core';
1811
import {addAriaReferencedId, getAriaReferenceIds, removeAriaReferencedId} from './aria-reference';
1912

2013

@@ -256,20 +249,3 @@ export class AriaDescriber implements OnDestroy {
256249
return element.nodeType === this._document.ELEMENT_NODE;
257250
}
258251
}
259-
260-
261-
/** @docs-private @deprecated @breaking-change 8.0.0 */
262-
export function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber, _document: any) {
263-
return parentDispatcher || new AriaDescriber(_document);
264-
}
265-
266-
/** @docs-private @deprecated @breaking-change 8.0.0 */
267-
export const ARIA_DESCRIBER_PROVIDER = {
268-
// If there is already an AriaDescriber available, use that. Otherwise, provide a new one.
269-
provide: AriaDescriber,
270-
deps: [
271-
[new Optional(), new SkipSelf(), AriaDescriber],
272-
DOCUMENT as InjectionToken<any>
273-
],
274-
useFactory: ARIA_DESCRIBER_PROVIDER_FACTORY
275-
};

src/cdk/a11y/focus-monitor/focus-monitor.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {
1414
Injectable,
1515
NgZone,
1616
OnDestroy,
17-
Optional,
1817
Output,
19-
SkipSelf,
2018
} from '@angular/core';
2119
import {Observable, of as observableOf, Subject, Subscription} from 'rxjs';
2220
import {coerceElement} from '@angular/cdk/coercion';
@@ -454,17 +452,3 @@ export class CdkMonitorFocus implements OnDestroy {
454452
this._monitorSubscription.unsubscribe();
455453
}
456454
}
457-
458-
/** @docs-private @deprecated @breaking-change 8.0.0 */
459-
export function FOCUS_MONITOR_PROVIDER_FACTORY(
460-
parentDispatcher: FocusMonitor, ngZone: NgZone, platform: Platform) {
461-
return parentDispatcher || new FocusMonitor(ngZone, platform);
462-
}
463-
464-
/** @docs-private @deprecated @breaking-change 8.0.0 */
465-
export const FOCUS_MONITOR_PROVIDER = {
466-
// If there is already a FocusMonitor available, use that. Otherwise, provide a new one.
467-
provide: FocusMonitor,
468-
deps: [[new Optional(), new SkipSelf(), FocusMonitor], NgZone, Platform],
469-
useFactory: FOCUS_MONITOR_PROVIDER_FACTORY
470-
};

src/cdk/a11y/key-manager/list-key-manager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ describe('Key managers', () => {
868868

869869
keyManager.updateActiveItem(1);
870870
expect(keyManager.activeItemIndex)
871-
.toBe(1, `Expected activeItemIndex to update after calling updateActiveItemIndex().`);
871+
.toBe(1, `Expected activeItemIndex to update after calling updateActiveItem().`);
872872
expect(itemList.items[1].focus).not.toHaveBeenCalledTimes(1);
873873
});
874874

src/cdk/a11y/key-manager/list-key-manager.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,6 @@ export class ListKeyManager<T extends ListKeyManagerOption> {
317317
this._activeItemIndex = index;
318318
}
319319

320-
/**
321-
* Allows setting of the activeItemIndex without any other effects.
322-
* @param index The new activeItemIndex.
323-
* @deprecated Use `updateActiveItem` instead.
324-
* @breaking-change 8.0.0
325-
*/
326-
updateActiveItemIndex(index: number): void {
327-
this.updateActiveItem(index);
328-
}
329-
330320
/**
331321
* This method sets the active item, given a list of items and the delta between the
332322
* currently active item and the new active item. It will calculate differently

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import {
1717
NgZone,
1818
OnDestroy,
1919
Optional,
20-
Provider,
21-
SkipSelf,
2220
} from '@angular/core';
2321
import {Subscription} from 'rxjs';
2422
import {
@@ -226,24 +224,3 @@ export class CdkAriaLive implements OnDestroy {
226224
}
227225
}
228226
}
229-
230-
231-
/** @docs-private @deprecated @breaking-change 8.0.0 */
232-
export function LIVE_ANNOUNCER_PROVIDER_FACTORY(
233-
parentAnnouncer: LiveAnnouncer, liveElement: any, _document: any, ngZone: NgZone) {
234-
return parentAnnouncer || new LiveAnnouncer(liveElement, ngZone, _document);
235-
}
236-
237-
238-
/** @docs-private @deprecated @breaking-change 8.0.0 */
239-
export const LIVE_ANNOUNCER_PROVIDER: Provider = {
240-
// If there is already a LiveAnnouncer available, use that. Otherwise, provide a new one.
241-
provide: LiveAnnouncer,
242-
deps: [
243-
[new Optional(), new SkipSelf(), LiveAnnouncer],
244-
[new Optional(), new Inject(LIVE_ANNOUNCER_ELEMENT_TOKEN)],
245-
DOCUMENT,
246-
NgZone,
247-
],
248-
useFactory: LIVE_ANNOUNCER_PROVIDER_FACTORY
249-
};

src/cdk/stepper/stepper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
342342
.pipe(startWith(this._layoutDirection()), takeUntil(this._destroyed))
343343
.subscribe(direction => this._keyManager.withHorizontalOrientation(direction));
344344

345-
this._keyManager.updateActiveItemIndex(this._selectedIndex);
345+
this._keyManager.updateActiveItem(this._selectedIndex);
346346

347347
this.steps.changes.pipe(takeUntil(this._destroyed)).subscribe(() => {
348348
if (!this.selected) {
@@ -456,7 +456,7 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
456456
// (e.g. checking whether focus is inside the active step), because we don't have a
457457
// reference to the elements that are rendering out the content.
458458
this._containsFocus() ? this._keyManager.setActiveItem(newIndex) :
459-
this._keyManager.updateActiveItemIndex(newIndex);
459+
this._keyManager.updateActiveItem(newIndex);
460460

461461
this._selectedIndex = newIndex;
462462
this._stateChanged();

src/material-experimental/mdc-chips/chip-listbox.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont
513513
let chipIndex: number = this._chips.toArray().indexOf(event.chip as MatChipOption);
514514

515515
if (this._isValidIndex(chipIndex)) {
516-
this._keyManager.updateActiveItemIndex(chipIndex);
516+
this._keyManager.updateActiveItem(chipIndex);
517517
}
518518
});
519519
}

src/material/chips/chip-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
756756
let chipIndex: number = this.chips.toArray().indexOf(event.chip);
757757

758758
if (this._isValidIndex(chipIndex)) {
759-
this._keyManager.updateActiveItemIndex(chipIndex);
759+
this._keyManager.updateActiveItem(chipIndex);
760760
}
761761
this.stateChanges.next();
762762
});

src/material/stepper/stepper.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ function assertCorrectKeyboardInteraction(fixture: ComponentFixture<any>,
11411141

11421142
// When the focus is on the last step and right arrow key is pressed, the focus should cycle
11431143
// through to the first step.
1144-
stepperComponent._keyManager.updateActiveItemIndex(2);
1144+
stepperComponent._keyManager.updateActiveItem(2);
11451145
stepHeaderEl = stepHeaders[2].nativeElement;
11461146
dispatchKeyboardEvent(stepHeaderEl, 'keydown', nextKey);
11471147
fixture.detectChanges();

src/material/tabs/paginated-tab-header.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte
126126
this._selectedIndex = value;
127127

128128
if (this._keyManager) {
129-
this._keyManager.updateActiveItemIndex(value);
129+
this._keyManager.updateActiveItem(value);
130130
}
131131
}
132132
}

tools/public_api_guard/cdk/a11y.d.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ export declare class ActiveDescendantKeyManager<T> extends ListKeyManager<Highli
66
setActiveItem(item: T): void;
77
}
88

9-
export declare const ARIA_DESCRIBER_PROVIDER: {
10-
provide: typeof AriaDescriber;
11-
deps: (Optional[] | InjectionToken<any>)[];
12-
useFactory: typeof ARIA_DESCRIBER_PROVIDER_FACTORY;
13-
};
14-
15-
export declare function ARIA_DESCRIBER_PROVIDER_FACTORY(parentDispatcher: AriaDescriber, _document: any): AriaDescriber;
16-
179
export declare class AriaDescriber implements OnDestroy {
1810
constructor(_document: any);
1911
describe(hostElement: Element, message: string | HTMLElement): void;
@@ -49,14 +41,6 @@ export declare class CdkTrapFocus implements OnDestroy, AfterContentInit, DoChec
4941
ngOnDestroy(): void;
5042
}
5143

52-
export declare const FOCUS_MONITOR_PROVIDER: {
53-
provide: typeof FocusMonitor;
54-
deps: (Optional[] | typeof NgZone | typeof Platform)[];
55-
useFactory: typeof FOCUS_MONITOR_PROVIDER_FACTORY;
56-
};
57-
58-
export declare function FOCUS_MONITOR_PROVIDER_FACTORY(parentDispatcher: FocusMonitor, ngZone: NgZone, platform: Platform): FocusMonitor;
59-
6044
export interface FocusableOption extends ListKeyManagerOption {
6145
focus(origin?: FocusOrigin): void;
6246
}
@@ -137,7 +121,6 @@ export declare class ListKeyManager<T extends ListKeyManagerOption> {
137121
skipPredicate(predicate: (item: T) => boolean): this;
138122
updateActiveItem(item: T): void;
139123
updateActiveItem(index: number): void;
140-
updateActiveItemIndex(index: number): void;
141124
withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this;
142125
withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this;
143126
withTypeAhead(debounceInterval?: number): this;
@@ -158,10 +141,6 @@ export declare const LIVE_ANNOUNCER_ELEMENT_TOKEN: InjectionToken<HTMLElement |
158141

159142
export declare function LIVE_ANNOUNCER_ELEMENT_TOKEN_FACTORY(): null;
160143

161-
export declare const LIVE_ANNOUNCER_PROVIDER: Provider;
162-
163-
export declare function LIVE_ANNOUNCER_PROVIDER_FACTORY(parentAnnouncer: LiveAnnouncer, liveElement: any, _document: any, ngZone: NgZone): LiveAnnouncer;
164-
165144
export declare class LiveAnnouncer implements OnDestroy {
166145
constructor(elementToken: any, _ngZone: NgZone, _document: any, _defaultOptions?: LiveAnnouncerDefaultOptions | undefined);
167146
announce(message: string, politeness?: AriaLivePoliteness): Promise<void>;

0 commit comments

Comments
 (0)