Skip to content

Commit 30e351e

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 27bb590 commit 30e351e

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();

src/material/tabs/tab-body.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
ViewChild,
2727
} from '@angular/core';
2828
import {AnimationEvent} from '@angular/animations';
29-
import {TemplatePortal, CdkPortalOutlet, PortalHostDirective} from '@angular/cdk/portal';
29+
import {TemplatePortal, CdkPortalOutlet} from '@angular/cdk/portal';
3030
import {Directionality, Direction} from '@angular/cdk/bidi';
3131
import {DOCUMENT} from '@angular/common';
3232
import {Subscription, Subject} from 'rxjs';
@@ -131,7 +131,7 @@ export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
131131
@Output() readonly _onCentered: EventEmitter<void> = new EventEmitter<void>(true);
132132

133133
/** The portal host inside of this container into which the tab body content will be loaded. */
134-
abstract _portalHost: PortalHostDirective;
134+
abstract _portalHost: CdkPortalOutlet;
135135

136136
/** The tab body content to display. */
137137
@Input('content') _content: TemplatePortal;
@@ -256,7 +256,7 @@ export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
256256
}
257257
})
258258
export class MatTabBody extends _MatTabBodyBase {
259-
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
259+
@ViewChild(CdkPortalOutlet) _portalHost: CdkPortalOutlet;
260260

261261
constructor(elementRef: ElementRef<HTMLElement>,
262262
@Optional() dir: Directionality,

src/youtube-player/youtube-player.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import {
4545
combineLatest as combineLatestOp,
4646
distinctUntilChanged,
4747
filter,
48-
flatMap,
4948
map,
5049
publish,
5150
scan,
@@ -56,6 +55,7 @@ import {
5655
withLatestFrom,
5756
switchMap,
5857
tap,
58+
mergeMap,
5959
} from 'rxjs/operators';
6060

6161
declare global {
@@ -586,7 +586,7 @@ function bindSuggestedQualityToPlayer(
586586
*/
587587
function waitUntilReady(onAbort: (player: UninitializedPlayer) => void):
588588
OperatorFunction<UninitializedPlayer | undefined, Player | undefined> {
589-
return flatMap(player => {
589+
return mergeMap(player => {
590590
if (!player) {
591591
return observableOf<Player|undefined>(undefined);
592592
}

tools/public_api_guard/material/tabs.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare abstract class _MatTabBodyBase implements OnInit, OnDestroy {
1313
_content: TemplatePortal;
1414
readonly _onCentered: EventEmitter<void>;
1515
readonly _onCentering: EventEmitter<number>;
16-
abstract _portalHost: PortalHostDirective;
16+
abstract _portalHost: CdkPortalOutlet;
1717
_position: MatTabBodyPositionState;
1818
_translateTabComplete: Subject<AnimationEvent>;
1919
animationDuration: string;
@@ -154,7 +154,7 @@ export declare class MatTab extends _MatTabMixinBase implements OnInit, CanDisab
154154
}
155155

156156
export declare class MatTabBody extends _MatTabBodyBase {
157-
_portalHost: PortalHostDirective;
157+
_portalHost: CdkPortalOutlet;
158158
constructor(elementRef: ElementRef<HTMLElement>, dir: Directionality, changeDetectorRef: ChangeDetectorRef);
159159
static ɵcmp: i0.ɵɵComponentDefWithMeta<MatTabBody, "mat-tab-body", never, {}, {}, never, never>;
160160
static ɵfac: i0.ɵɵFactoryDef<MatTabBody, [null, { optional: true; }, null]>;

0 commit comments

Comments
 (0)