Skip to content

Commit c501db6

Browse files
crisbetoandrewseguin
authored andcommitted
refactor(button): constructor changes for 8.0 (#15734)
Handles the constructor breaking changes for 8.0 in `material/button`. BREAKING CHANGES: * `_platform` parameter has been removed from the `MatButton` constructor and the `_animationMode` is now required. * `platform` parameter has been removed from the `MatAnchor` constructor and the `animationMode` is now required.
1 parent 1b13be5 commit c501db6

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

src/lib/button/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ng_module(
1414
"@npm//@angular/core",
1515
"@npm//@angular/platform-browser",
1616
"@npm//@angular/animations",
17-
"//src/cdk/platform",
1817
"//src/cdk/a11y",
1918
"//src/lib/core",
2019
],

src/lib/button/button.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import {FocusMonitor} from '@angular/cdk/a11y';
10-
import {Platform} from '@angular/cdk/platform';
1110
import {
1211
ChangeDetectionStrategy,
1312
Component,
@@ -92,14 +91,8 @@ export class MatButton extends _MatButtonMixinBase
9291
@ViewChild(MatRipple, {static: false}) ripple: MatRipple;
9392

9493
constructor(elementRef: ElementRef,
95-
/**
96-
* @deprecated Platform checks for SSR are no longer needed
97-
* @breaking-change 8.0.0
98-
*/
99-
_platform: Platform,
10094
private _focusMonitor: FocusMonitor,
101-
// @breaking-change 8.0.0 `_animationMode` parameter to be made required.
102-
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode?: string) {
95+
@Optional() @Inject(ANIMATION_MODULE_TYPE) public _animationMode: string) {
10396
super(elementRef);
10497

10598
// For each of the variant selectors that is prevent in the button's host
@@ -169,12 +162,10 @@ export class MatAnchor extends MatButton {
169162
@Input() tabIndex: number;
170163

171164
constructor(
172-
platform: Platform,
173165
focusMonitor: FocusMonitor,
174166
elementRef: ElementRef,
175-
// @breaking-change 8.0.0 `animationMode` parameter to be made required.
176-
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) {
177-
super(elementRef, platform, focusMonitor, animationMode);
167+
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string) {
168+
super(elementRef, focusMonitor, animationMode);
178169
}
179170

180171
_haltDisabledEvents(event: Event) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
2222
{
2323
pr: 'https://github.com/angular/material2/pull/15757',
2424
changes: ['MatBadge']
25+
},
26+
{
27+
pr: 'https://github.com/angular/material2/issues/15734',
28+
changes: ['MatButton', 'MatAnchor']
2529
}
2630
],
2731

tools/public_api_guard/lib/button.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ export declare const _MatButtonMixinBase: CanDisableRippleCtor & CanDisableCtor
22

33
export declare class MatAnchor extends MatButton {
44
tabIndex: number;
5-
constructor(platform: Platform, focusMonitor: FocusMonitor, elementRef: ElementRef, animationMode?: string);
5+
constructor(focusMonitor: FocusMonitor, elementRef: ElementRef, animationMode: string);
66
_haltDisabledEvents(event: Event): void;
77
}
88

99
export declare class MatButton extends _MatButtonMixinBase implements OnDestroy, CanDisable, CanColor, CanDisableRipple {
10-
_animationMode?: string | undefined;
10+
_animationMode: string;
1111
readonly isIconButton: boolean;
1212
readonly isRoundButton: boolean;
1313
ripple: MatRipple;
14-
constructor(elementRef: ElementRef,
15-
_platform: Platform, _focusMonitor: FocusMonitor, _animationMode?: string | undefined);
14+
constructor(elementRef: ElementRef, _focusMonitor: FocusMonitor, _animationMode: string);
1615
_getHostElement(): any;
1716
_hasHostAttributes(...attributes: string[]): boolean;
1817
_isRippleDisabled(): boolean;

0 commit comments

Comments
 (0)