Skip to content

Commit 49fb124

Browse files
crisbetommalerba
authored andcommitted
refactor(material/core): clean up deprecation API usages (#21597)
Cleans a handful of usages of deprecated APIs. (cherry picked from commit 6bab3df)
1 parent 01cbebe commit 49fb124

File tree

13 files changed

+18
-24
lines changed

13 files changed

+18
-24
lines changed

src/cdk-experimental/column-resize/event-dispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class HeaderRowEventDispatcher {
4242
* Emits the header that is currently hovered or hosting an active resize event (with active
4343
* taking precedence).
4444
*/
45-
readonly headerRowHoveredOrActiveDistinct = combineLatest(
45+
readonly headerRowHoveredOrActiveDistinct = combineLatest([
4646
this.headerCellHoveredDistinct.pipe(
4747
map(cell => _closest(cell, HEADER_ROW_SELECTOR)),
4848
startWith(null),
@@ -53,7 +53,7 @@ export class HeaderRowEventDispatcher {
5353
startWith(null),
5454
distinctUntilChanged(),
5555
),
56-
).pipe(
56+
]).pipe(
5757
skip(1), // Ignore initial [null, null] emission.
5858
map(([hovered, active]) => active || hovered),
5959
distinctUntilChanged(),

src/cdk-experimental/dialog/dialog-ref.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ export class DialogRef<T, R = any> {
115115
* @param size New size for the overlay.
116116
*/
117117
updateSize(size: OverlaySizeConfig): this {
118-
if (size.width) {
119-
this._getPositionStrategy().width(size.width.toString());
120-
}
121-
if (size.height) {
122-
this._getPositionStrategy().height(size.height.toString());
123-
}
124118
this._overlayRef.updateSize(size);
125119
this._overlayRef.updatePosition();
126120
return this;

src/cdk/scrolling/virtual-for-of.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export class CdkVirtualForOf<T> implements
154154
dataStream: Observable<T[] | ReadonlyArray<T>> = this._dataSourceChanges
155155
.pipe(
156156
// Start off with null `DataSource`.
157-
startWith(null!),
157+
startWith(null),
158158
// Bundle up the previous and current data sources so we can work with both.
159159
pairwise(),
160160
// Use `_changeDataSource` to disconnect from the previous data source and connect to the

src/cdk/scrolling/virtual-scroll-viewport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O
185185
this.elementScrolled()
186186
.pipe(
187187
// Start off with a fake scroll event so we properly detect our initial position.
188-
startWith(null!),
188+
startWith(null),
189189
// Collect multiple events into one until the next animation frame. This way if
190190
// there are multiple scroll events in the same frame we only need to recheck
191191
// our layout once.

src/material-experimental/mdc-paginator/paginator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('MDC-based MatPaginator', () => {
8383
it('should re-render when the i18n labels change', () => {
8484
const fixture = createComponent(MatPaginatorApp);
8585
const label = fixture.nativeElement.querySelector('.mat-mdc-paginator-page-size-label');
86-
const intl = TestBed.get<MatPaginatorIntl>(MatPaginatorIntl);
86+
const intl = TestBed.inject(MatPaginatorIntl);
8787

8888
intl.itemsPerPageLabel = '1337 items per page';
8989
intl.changes.next();

src/material-experimental/mdc-tabs/tab-body.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
matTabsAnimations,
2626
_MatTabBodyBase,
2727
} from '@angular/material/tabs';
28-
import {PortalHostDirective} from '@angular/cdk/portal';
28+
import {CdkPortalOutlet} from '@angular/cdk/portal';
2929
import {Directionality} from '@angular/cdk/bidi';
3030
import {DOCUMENT} from '@angular/common';
3131

@@ -62,7 +62,7 @@ export class MatTabBodyPortal extends BaseMatTabBodyPortal {
6262
},
6363
})
6464
export class MatTabBody extends _MatTabBodyBase {
65-
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
65+
@ViewChild(CdkPortalOutlet) _portalHost: CdkPortalOutlet;
6666

6767
constructor(elementRef: ElementRef<HTMLElement>,
6868
@Optional() dir: Directionality,

src/material/dialog/dialog-ref.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export class MatDialogRef<T, R = any> {
200200
* @param height New height of the dialog.
201201
*/
202202
updateSize(width: string = '', height: string = ''): this {
203-
this._getPositionStrategy().width(width).height(height);
203+
this._overlayRef.updateSize({width, height});
204204
this._overlayRef.updatePosition();
205205
return this;
206206
}

src/material/expansion/expansion-panel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
209209
if (this._lazyContent) {
210210
// Render the content as soon as the panel becomes open.
211211
this.opened.pipe(
212-
startWith(null!),
212+
startWith(null),
213213
filter(() => this.expanded && !this._portal),
214214
take(1)
215215
).subscribe(() => {

src/material/form-field/form-field.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ export class MatFormField extends _MatFormFieldMixinBase
324324
}
325325

326326
// Subscribe to changes in the child control state in order to update the form field UI.
327-
control.stateChanges.pipe(startWith(null!)).subscribe(() => {
327+
control.stateChanges.pipe(startWith(null)).subscribe(() => {
328328
this._validatePlaceholders();
329329
this._syncDescribedByIds();
330330
this._changeDetectorRef.markForCheck();

src/material/paginator/paginator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('MatPaginator', () => {
8383
it('should re-render when the i18n labels change', () => {
8484
const fixture = createComponent(MatPaginatorApp);
8585
const label = fixture.nativeElement.querySelector('.mat-paginator-page-size-label');
86-
const intl = TestBed.get<MatPaginatorIntl>(MatPaginatorIntl);
86+
const intl = TestBed.inject(MatPaginatorIntl);
8787

8888
intl.itemsPerPageLabel = '1337 items per page';
8989
intl.changes.next();

0 commit comments

Comments
 (0)