Skip to content

Commit aec24de

Browse files
committed
refactor(material/list): remove deprecated APIs for version 13
Removes the APIs that were marked for removal in version 13 in the `material/list` package. BREAKING CHANGE: * `mat-list-item-avatar` CSS class has been renamed to `mat-list-item-with-avatar`. * `MatSelectionListChange.option` has been removed. Use `MatSelectionListChange.options` instead. * `MatSelectionList.tabIndex` input has been removed. * `tabIndex` parameter of the `MatSelectionList` constructor has been removed. * `_focusMonitor` parameter of the `MatSelectionList` constructor is now required. * `getHarnessLoaderForContent` has been removed from the various test item harnesses. Use `getChildLoader(MatListItemSection.CONTENT)` instead.
1 parent c2a20c4 commit aec24de

File tree

7 files changed

+19
-42
lines changed

7 files changed

+19
-42
lines changed

src/material/list/list.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ export class MatListSubheaderCssMatStyler {}
178178
host: {
179179
'class': 'mat-list-item mat-focus-indicator',
180180
'[class.mat-list-item-disabled]': 'disabled',
181-
// @breaking-change 8.0.0 Remove `mat-list-item-avatar` in favor of `mat-list-item-with-avatar`.
182-
'[class.mat-list-item-avatar]': '_avatar || _icon',
183181
'[class.mat-list-item-with-avatar]': '_avatar || _icon',
184182
},
185183
inputs: ['disableRipple'],

src/material/list/selection-list.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
} from '@angular/cdk/keycodes';
2020
import {
2121
AfterContentInit,
22-
Attribute,
2322
ChangeDetectionStrategy,
2423
ChangeDetectorRef,
2524
Component,
@@ -66,12 +65,6 @@ export class MatSelectionListChange {
6665
constructor(
6766
/** Reference to the selection list that emitted the event. */
6867
public source: MatSelectionList,
69-
/**
70-
* Reference to the option that has been changed.
71-
* @deprecated Use `options` instead, because some events may change more than one option.
72-
* @breaking-change 12.0.0
73-
*/
74-
public option: MatListOption,
7568
/** Reference to the options that have been changed. */
7669
public options: MatListOption[]) {}
7770
}
@@ -364,12 +357,6 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
364357
@Output() readonly selectionChange: EventEmitter<MatSelectionListChange> =
365358
new EventEmitter<MatSelectionListChange>();
366359

367-
/**
368-
* Tabindex of the selection list.
369-
* @breaking-change 11.0.0 Remove `tabIndex` input.
370-
*/
371-
@Input() tabIndex: number = 0;
372-
373360
/** Theme color of the selection list. This sets the checkbox color for all list options. */
374361
@Input() color: ThemePalette = 'accent';
375362

@@ -433,11 +420,8 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
433420
private _isDestroyed: boolean;
434421

435422
constructor(private _element: ElementRef<HTMLElement>,
436-
// @breaking-change 11.0.0 Remove `tabIndex` parameter.
437-
@Attribute('tabindex') tabIndex: string,
438423
private _changeDetector: ChangeDetectorRef,
439-
// @breaking-change 11.0.0 `_focusMonitor` parameter to become required.
440-
private _focusMonitor?: FocusMonitor) {
424+
private _focusMonitor: FocusMonitor) {
441425
super();
442426
}
443427

@@ -482,8 +466,7 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
482466
}
483467
});
484468

485-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
486-
this._focusMonitor?.monitor(this._element)
469+
this._focusMonitor.monitor(this._element)
487470
.pipe(takeUntil(this._destroyed))
488471
.subscribe(origin => {
489472
if (origin === 'keyboard' || origin === 'program') {
@@ -510,8 +493,7 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
510493
}
511494

512495
ngOnDestroy() {
513-
// @breaking-change 11.0.0 Remove null assertion once _focusMonitor is required.
514-
this._focusMonitor?.stopMonitoring(this._element);
496+
this._focusMonitor.stopMonitoring(this._element);
515497
this._destroyed.next();
516498
this._destroyed.complete();
517499
this._isDestroyed = true;
@@ -604,7 +586,7 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
604586

605587
/** Emits a change event if the selected state of an option changed. */
606588
_emitChangeEvent(options: MatListOption[]) {
607-
this.selectionChange.emit(new MatSelectionListChange(this, options[0], options));
589+
this.selectionChange.emit(new MatSelectionListChange(this, options));
608590
}
609591

610592
/** Implemented as part of ControlValueAccessor. */

src/material/list/testing/list-item-harness-base.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import {
1010
ComponentHarness,
1111
ComponentHarnessConstructor,
12-
HarnessLoader,
1312
HarnessPredicate,
1413
ContentContainerComponentHarness,
1514
parallel,
@@ -88,13 +87,4 @@ export abstract class MatListItemHarnessBase
8887
async hasIcon(): Promise<boolean> {
8988
return !!await this._icon();
9089
}
91-
92-
/**
93-
* Gets a `HarnessLoader` used to get harnesses within the list item's content.
94-
* @deprecated Use `getChildLoader(MatListItemSection.CONTENT)` or `getHarness` instead.
95-
* @breaking-change 12.0.0
96-
*/
97-
async getHarnessLoaderForContent(): Promise<HarnessLoader> {
98-
return this.getChildLoader(MatListItemSection.CONTENT);
99-
}
10090
}

src/material/schematics/ng-update/data/constructor-checks.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
1818
{
1919
pr: 'https://github.com/angular/components/pull/23389',
2020
changes: ['MatFormField']
21+
},
22+
{
23+
pr: 'https://github.com/angular/components/pull/23327',
24+
changes: ['MatSelectionList', 'MatSelectionListChange']
2125
}
2226
],
2327
[TargetVersion.V12]: [

src/material/schematics/ng-update/data/css-selectors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export interface MaterialCssSelectorData {
2828
}
2929

3030
export const cssSelectors: VersionChanges<MaterialCssSelectorData> = {
31+
[TargetVersion.V13]: [
32+
{
33+
pr: 'https://github.com/angular/components/pull/23327',
34+
changes: [
35+
{replace: '.mat-list-item-avatar', replaceWith: '.mat-list-item-with-avatar'}
36+
]
37+
}
38+
],
3139
[TargetVersion.V6]: [
3240
{
3341
pr: 'https://github.com/angular/components/pull/10296',

tools/public_api_guard/material/list-testing.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { ComponentHarness } from '@angular/cdk/testing';
99
import { ComponentHarnessConstructor } from '@angular/cdk/testing';
1010
import { ContentContainerComponentHarness } from '@angular/cdk/testing';
1111
import { DividerHarnessFilters } from '@angular/material/divider/testing';
12-
import { HarnessLoader } from '@angular/cdk/testing';
1312
import { HarnessPredicate } from '@angular/cdk/testing';
1413
import { MatDividerHarness } from '@angular/material/divider/testing';
1514
import { MatListOptionCheckboxPosition } from '@angular/material/list';

tools/public_api_guard/material/list.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class MatNavList extends _MatListBase implements CanDisable, CanDisableRi
197197

198198
// @public
199199
export class MatSelectionList extends _MatSelectionListBase implements CanDisableRipple, AfterContentInit, ControlValueAccessor, OnDestroy, OnChanges {
200-
constructor(_element: ElementRef<HTMLElement>, tabIndex: string, _changeDetector: ChangeDetectorRef, _focusMonitor?: FocusMonitor | undefined);
200+
constructor(_element: ElementRef<HTMLElement>, _changeDetector: ChangeDetectorRef, _focusMonitor: FocusMonitor);
201201
color: ThemePalette;
202202
compareWith: (o1: any, o2: any) => boolean;
203203
deselectAll(): MatListOption[];
@@ -232,24 +232,20 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl
232232
readonly selectionChange: EventEmitter<MatSelectionListChange>;
233233
setDisabledState(isDisabled: boolean): void;
234234
_setFocusedOption(option: MatListOption): void;
235-
tabIndex: number;
236235
_tabIndex: number;
237236
_value: string[] | null;
238237
writeValue(values: string[]): void;
239238
// (undocumented)
240-
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "tabIndex": "tabIndex"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
239+
static ɵcmp: i0.ɵɵComponentDeclaration<MatSelectionList, "mat-selection-list", ["matSelectionList"], { "disableRipple": "disableRipple"; "color": "color"; "compareWith": "compareWith"; "disabled": "disabled"; "multiple": "multiple"; }, { "selectionChange": "selectionChange"; }, ["options"], ["*"]>;
241240
// (undocumented)
242-
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, [null, { attribute: "tabindex"; }, null, null]>;
241+
static ɵfac: i0.ɵɵFactoryDeclaration<MatSelectionList, never>;
243242
}
244243

245244
// @public
246245
export class MatSelectionListChange {
247246
constructor(
248247
source: MatSelectionList,
249-
option: MatListOption,
250248
options: MatListOption[]);
251-
// @deprecated
252-
option: MatListOption;
253249
options: MatListOption[];
254250
source: MatSelectionList;
255251
}

0 commit comments

Comments
 (0)