diff --git a/src/material-experimental/mdc-chips/chip-row.ts b/src/material-experimental/mdc-chips/chip-row.ts index 393fec71341d..1094bb67941c 100644 --- a/src/material-experimental/mdc-chips/chip-row.ts +++ b/src/material-experimental/mdc-chips/chip-row.ts @@ -100,7 +100,6 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn changeDetectorRef: ChangeDetectorRef, elementRef: ElementRef, ngZone: NgZone, @Optional() dir: Directionality, - // @breaking-change 8.0.0 `animationMode` parameter to become required. @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) { super(changeDetectorRef, elementRef, ngZone, dir, animationMode); } diff --git a/src/material-experimental/mdc-chips/chip.ts b/src/material-experimental/mdc-chips/chip.ts index 01cd7c13af3d..bc354c1300b0 100644 --- a/src/material-experimental/mdc-chips/chip.ts +++ b/src/material-experimental/mdc-chips/chip.ts @@ -355,7 +355,6 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte public _changeDetectorRef: ChangeDetectorRef, readonly _elementRef: ElementRef, protected _ngZone: NgZone, @Optional() private _dir: Directionality, - // @breaking-change 8.0.0 `animationMode` parameter to become required. @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) { super(_elementRef); this._chipFoundation = new MDCChipFoundation(this._chipAdapter); diff --git a/src/material/chips/chip.ts b/src/material/chips/chip.ts index 6c4bec0087c2..b78c821e919e 100644 --- a/src/material/chips/chip.ts +++ b/src/material/chips/chip.ts @@ -283,14 +283,11 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes private _ngZone: NgZone, platform: Platform, @Optional() @Inject(MAT_RIPPLE_GLOBAL_OPTIONS) - globalRippleOptions: RippleGlobalOptions | null, - // @breaking-change 8.0.0 `animationMode` parameter to become required. + globalRippleOptions: RippleGlobalOptions | null, + private _changeDetectorRef: ChangeDetectorRef, + @Inject(DOCUMENT) _document: any, @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string, - // @breaking-change 9.0.0 `_changeDetectorRef` parameter to become required. - private _changeDetectorRef?: ChangeDetectorRef, - @Attribute('tabindex') tabIndex?: string, - // @breaking-change 11.0.0 `_document` parameter to become required. - @Optional() @Inject(DOCUMENT) _document?: any) { + @Attribute('tabindex') tabIndex?: string) { super(_elementRef); this._addHostClassName(); @@ -298,7 +295,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes // Dynamically create the ripple target, append it within the chip, and use it as the // chip's ripple target. Adding the class '.mat-chip-ripple' ensures that it will have // the proper styles. - this._chipRippleTarget = (_document || document).createElement('div'); + this._chipRippleTarget = _document.createElement('div'); this._chipRippleTarget.classList.add('mat-chip-ripple'); this._elementRef.nativeElement.appendChild(this._chipRippleTarget); this._chipRipple = new RippleRenderer(this, _ngZone, this._chipRippleTarget, platform); @@ -332,7 +329,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes if (!this._selected) { this._selected = true; this._dispatchSelectionChange(); - this._markForCheck(); + this._changeDetectorRef.markForCheck(); } } @@ -341,7 +338,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes if (this._selected) { this._selected = false; this._dispatchSelectionChange(); - this._markForCheck(); + this._changeDetectorRef.markForCheck(); } } @@ -350,7 +347,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes if (!this._selected) { this._selected = true; this._dispatchSelectionChange(true); - this._markForCheck(); + this._changeDetectorRef.markForCheck(); } } @@ -358,7 +355,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes toggleSelected(isUserInput: boolean = false): boolean { this._selected = !this.selected; this._dispatchSelectionChange(isUserInput); - this._markForCheck(); + this._changeDetectorRef.markForCheck(); return this.selected; } @@ -441,13 +438,6 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes }); } - private _markForCheck() { - // @breaking-change 9.0.0 Remove this method once the _changeDetectorRef is a required param. - if (this._changeDetectorRef) { - this._changeDetectorRef.markForCheck(); - } - } - static ngAcceptInputType_selected: BooleanInput; static ngAcceptInputType_selectable: BooleanInput; static ngAcceptInputType_removable: BooleanInput; @@ -480,11 +470,8 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes export class MatChipRemove { constructor( protected _parentChip: MatChip, - // @breaking-change 11.0.0 `elementRef` parameter to be made required. - elementRef?: ElementRef) { - - // @breaking-change 11.0.0 Remove null check for `elementRef`. - if (elementRef && elementRef.nativeElement.nodeName === 'BUTTON') { + elementRef: ElementRef) { + if (elementRef.nativeElement.nodeName === 'BUTTON') { elementRef.nativeElement.setAttribute('type', 'button'); } } diff --git a/src/material/schematics/ng-update/data/constructor-checks.ts b/src/material/schematics/ng-update/data/constructor-checks.ts index d005536197a4..38393ae08664 100644 --- a/src/material/schematics/ng-update/data/constructor-checks.ts +++ b/src/material/schematics/ng-update/data/constructor-checks.ts @@ -14,6 +14,12 @@ import {ConstructorChecksUpgradeData, TargetVersion, VersionChanges} from '@angu * automatically through type checking. */ export const constructorChecks: VersionChanges = { + [TargetVersion.V11]: [ + { + pr: 'https://github.com/angular/components/issues/20463', + changes: ['MatChip', 'MatChipRemove'] + } + ], [TargetVersion.V10]: [ { pr: 'https://github.com/angular/components/pull/19307', diff --git a/tools/public_api_guard/material/chips.d.ts b/tools/public_api_guard/material/chips.d.ts index 7340b89e5c6e..69c889294f5d 100644 --- a/tools/public_api_guard/material/chips.d.ts +++ b/tools/public_api_guard/material/chips.d.ts @@ -39,7 +39,7 @@ export declare class MatChip extends _MatChipMixinBase implements FocusableOptio trailingIcon: MatChipTrailingIcon; get value(): any; set value(value: any); - constructor(_elementRef: ElementRef, _ngZone: NgZone, platform: Platform, globalRippleOptions: RippleGlobalOptions | null, animationMode?: string, _changeDetectorRef?: ChangeDetectorRef | undefined, tabIndex?: string, _document?: any); + constructor(_elementRef: ElementRef, _ngZone: NgZone, platform: Platform, globalRippleOptions: RippleGlobalOptions | null, _changeDetectorRef: ChangeDetectorRef, _document: any, animationMode?: string, tabIndex?: string); _addHostClassName(): void; _blur(): void; _handleClick(event: Event): void; @@ -58,7 +58,7 @@ export declare class MatChip extends _MatChipMixinBase implements FocusableOptio static ngAcceptInputType_selected: BooleanInput; static ngAcceptInputType_tabIndex: NumberInput; static ɵdir: i0.ɵɵDirectiveDefWithMeta; - static ɵfac: i0.ɵɵFactoryDef; + static ɵfac: i0.ɵɵFactoryDef; } export declare class MatChipAvatar { @@ -193,7 +193,7 @@ export declare class MatChipListChange { export declare class MatChipRemove { protected _parentChip: MatChip; - constructor(_parentChip: MatChip, elementRef?: ElementRef); + constructor(_parentChip: MatChip, elementRef: ElementRef); _handleClick(event: Event): void; static ɵdir: i0.ɵɵDirectiveDefWithMeta; static ɵfac: i0.ɵɵFactoryDef;