Skip to content

refactor(material/core): clean up deprecated API usages #21597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cdk-experimental/column-resize/event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class HeaderRowEventDispatcher {
* Emits the header that is currently hovered or hosting an active resize event (with active
* taking precedence).
*/
readonly headerRowHoveredOrActiveDistinct = combineLatest(
readonly headerRowHoveredOrActiveDistinct = combineLatest([
this.headerCellHoveredDistinct.pipe(
map(cell => _closest(cell, HEADER_ROW_SELECTOR)),
startWith(null),
Expand All @@ -53,7 +53,7 @@ export class HeaderRowEventDispatcher {
startWith(null),
distinctUntilChanged(),
),
).pipe(
]).pipe(
skip(1), // Ignore initial [null, null] emission.
map(([hovered, active]) => active || hovered),
distinctUntilChanged(),
Expand Down
6 changes: 0 additions & 6 deletions src/cdk-experimental/dialog/dialog-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ export class DialogRef<T, R = any> {
* @param size New size for the overlay.
*/
updateSize(size: OverlaySizeConfig): this {
if (size.width) {
this._getPositionStrategy().width(size.width.toString());
}
if (size.height) {
this._getPositionStrategy().height(size.height.toString());
}
this._overlayRef.updateSize(size);
this._overlayRef.updatePosition();
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/scrolling/virtual-for-of.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class CdkVirtualForOf<T> implements
dataStream: Observable<T[] | ReadonlyArray<T>> = this._dataSourceChanges
.pipe(
// Start off with null `DataSource`.
startWith(null!),
startWith(null),
// Bundle up the previous and current data sources so we can work with both.
pairwise(),
// Use `_changeDataSource` to disconnect from the previous data source and connect to the
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/scrolling/virtual-scroll-viewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O
this.elementScrolled()
.pipe(
// Start off with a fake scroll event so we properly detect our initial position.
startWith(null!),
startWith(null),
// Collect multiple events into one until the next animation frame. This way if
// there are multiple scroll events in the same frame we only need to recheck
// our layout once.
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('MDC-based MatPaginator', () => {
it('should re-render when the i18n labels change', () => {
const fixture = createComponent(MatPaginatorApp);
const label = fixture.nativeElement.querySelector('.mat-mdc-paginator-page-size-label');
const intl = TestBed.get<MatPaginatorIntl>(MatPaginatorIntl);
const intl = TestBed.inject(MatPaginatorIntl);

intl.itemsPerPageLabel = '1337 items per page';
intl.changes.next();
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-tabs/tab-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
matTabsAnimations,
_MatTabBodyBase,
} from '@angular/material/tabs';
import {PortalHostDirective} from '@angular/cdk/portal';
import {CdkPortalOutlet} from '@angular/cdk/portal';
import {Directionality} from '@angular/cdk/bidi';
import {DOCUMENT} from '@angular/common';

Expand Down Expand Up @@ -62,7 +62,7 @@ export class MatTabBodyPortal extends BaseMatTabBodyPortal {
},
})
export class MatTabBody extends _MatTabBodyBase {
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
@ViewChild(CdkPortalOutlet) _portalHost: CdkPortalOutlet;

constructor(elementRef: ElementRef<HTMLElement>,
@Optional() dir: Directionality,
Expand Down
2 changes: 1 addition & 1 deletion src/material/dialog/dialog-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export class MatDialogRef<T, R = any> {
* @param height New height of the dialog.
*/
updateSize(width: string = '', height: string = ''): this {
this._getPositionStrategy().width(width).height(height);
this._overlayRef.updateSize({width, height});
this._overlayRef.updatePosition();
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/expansion/expansion-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI
if (this._lazyContent) {
// Render the content as soon as the panel becomes open.
this.opened.pipe(
startWith(null!),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I think this was necessary to avoid some rxjs typing breakage in google at some point. We'll see if it breaks anything in the presubmit.

startWith(null),
filter(() => this.expanded && !this._portal),
take(1)
).subscribe(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class MatFormField extends _MatFormFieldMixinBase
}

// Subscribe to changes in the child control state in order to update the form field UI.
control.stateChanges.pipe(startWith(null!)).subscribe(() => {
control.stateChanges.pipe(startWith(null)).subscribe(() => {
this._validatePlaceholders();
this._syncDescribedByIds();
this._changeDetectorRef.markForCheck();
Expand Down
2 changes: 1 addition & 1 deletion src/material/paginator/paginator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('MatPaginator', () => {
it('should re-render when the i18n labels change', () => {
const fixture = createComponent(MatPaginatorApp);
const label = fixture.nativeElement.querySelector('.mat-paginator-page-size-label');
const intl = TestBed.get<MatPaginatorIntl>(MatPaginatorIntl);
const intl = TestBed.inject(MatPaginatorIntl);

intl.itemsPerPageLabel = '1337 items per page';
intl.changes.next();
Expand Down
6 changes: 3 additions & 3 deletions src/material/tabs/tab-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
ViewChild,
} from '@angular/core';
import {AnimationEvent} from '@angular/animations';
import {TemplatePortal, CdkPortalOutlet, PortalHostDirective} from '@angular/cdk/portal';
import {TemplatePortal, CdkPortalOutlet} from '@angular/cdk/portal';
import {Directionality, Direction} from '@angular/cdk/bidi';
import {DOCUMENT} from '@angular/common';
import {Subscription, Subject} from 'rxjs';
Expand Down Expand Up @@ -131,7 +131,7 @@ export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
@Output() readonly _onCentered: EventEmitter<void> = new EventEmitter<void>(true);

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

/** The tab body content to display. */
@Input('content') _content: TemplatePortal;
Expand Down Expand Up @@ -256,7 +256,7 @@ export abstract class _MatTabBodyBase implements OnInit, OnDestroy {
}
})
export class MatTabBody extends _MatTabBodyBase {
@ViewChild(PortalHostDirective) _portalHost: PortalHostDirective;
@ViewChild(CdkPortalOutlet) _portalHost: CdkPortalOutlet;

constructor(elementRef: ElementRef<HTMLElement>,
@Optional() dir: Directionality,
Expand Down
4 changes: 2 additions & 2 deletions src/youtube-player/youtube-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
combineLatest as combineLatestOp,
distinctUntilChanged,
filter,
flatMap,
map,
publish,
scan,
Expand All @@ -56,6 +55,7 @@ import {
withLatestFrom,
switchMap,
tap,
mergeMap,
} from 'rxjs/operators';

declare global {
Expand Down Expand Up @@ -586,7 +586,7 @@ function bindSuggestedQualityToPlayer(
*/
function waitUntilReady(onAbort: (player: UninitializedPlayer) => void):
OperatorFunction<UninitializedPlayer | undefined, Player | undefined> {
return flatMap(player => {
return mergeMap(player => {
if (!player) {
return observableOf<Player|undefined>(undefined);
}
Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/tabs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export declare abstract class _MatTabBodyBase implements OnInit, OnDestroy {
_content: TemplatePortal;
readonly _onCentered: EventEmitter<void>;
readonly _onCentering: EventEmitter<number>;
abstract _portalHost: PortalHostDirective;
abstract _portalHost: CdkPortalOutlet;
_position: MatTabBodyPositionState;
_translateTabComplete: Subject<AnimationEvent>;
animationDuration: string;
Expand Down Expand Up @@ -154,7 +154,7 @@ export declare class MatTab extends _MatTabMixinBase implements OnInit, CanDisab
}

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