Skip to content

Commit 5388a38

Browse files
crisbetoandrewseguin
authored andcommitted
refactor(progress-spinner): breaking constructor changes for 8.0 (#15761)
Handles the breaking constructor changes for `MatProgressSpinner` and `MatSpinner`. Also takes the chance to remove some unnecessary private properties. BREAKING CHANGES: * The `animationMode` mode parameter is now required in the `MatProgressSpinner` and `MatSpinner` constructors. * The `_elementRef` parameter has changed from `ElementRef<any>` to `ElementRef<HTMLElement>` in the `MatProgressSpinner` and `MatSpinner` constructors.
1 parent c501db6 commit 5388a38

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/lib/progress-spinner/progress-spinner.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
139139
private static styleTag: HTMLStyleElement|null = null;
140140

141141
/** Whether the _mat-animation-noopable class should be applied, disabling animations. */
142-
_noopAnimations: boolean = this.animationMode === 'NoopAnimations' && (
143-
!!this.defaults && !this.defaults._forceAnimations);
142+
_noopAnimations: boolean;
144143

145144
/** The diameter of the progress spinner (will set width and height of svg). */
146145
@Input()
@@ -175,16 +174,17 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
175174
this._value = Math.max(0, Math.min(100, coerceNumberProperty(newValue)));
176175
}
177176

178-
constructor(public _elementRef: ElementRef,
177+
constructor(public _elementRef: ElementRef<HTMLElement>,
179178
platform: Platform,
180179
@Optional() @Inject(DOCUMENT) private _document: any,
181-
// @breaking-change 8.0.0 animationMode and defaults parameters to be made required.
182-
@Optional() @Inject(ANIMATION_MODULE_TYPE) private animationMode?: string,
180+
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
183181
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
184-
private defaults?: MatProgressSpinnerDefaultOptions) {
182+
defaults?: MatProgressSpinnerDefaultOptions) {
185183

186184
super(_elementRef);
187185
this._fallbackAnimation = platform.EDGE || platform.TRIDENT;
186+
this._noopAnimations = animationMode === 'NoopAnimations' &&
187+
(!!defaults && !defaults._forceAnimations);
188188

189189
if (defaults) {
190190
if (defaults.diameter) {
@@ -291,10 +291,9 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
291291
encapsulation: ViewEncapsulation.None,
292292
})
293293
export class MatSpinner extends MatProgressSpinner {
294-
constructor(elementRef: ElementRef, platform: Platform,
294+
constructor(elementRef: ElementRef<HTMLElement>, platform: Platform,
295295
@Optional() @Inject(DOCUMENT) document: any,
296-
// @breaking-change 8.0.0 animationMode and defaults parameters to be made required.
297-
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string,
296+
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
298297
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
299298
defaults?: MatProgressSpinnerDefaultOptions) {
300299
super(elementRef, platform, document, animationMode, defaults);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export const constructorChecks: VersionChanges<ConstructorChecksUpgradeData> = {
2626
{
2727
pr: 'https://github.com/angular/material2/issues/15734',
2828
changes: ['MatButton', 'MatAnchor']
29+
},
30+
{
31+
pr: 'https://github.com/angular/material2/pull/15761',
32+
changes: ['MatSpinner', 'MatProgressSpinner']
2933
}
3034
],
3135

tools/public_api_guard/lib/progress-spinner.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export declare function MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS_FACTORY(): MatProgr
77
export declare class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements CanColor {
88
readonly _circleRadius: number;
99
readonly _circleStrokeWidth: number;
10-
_elementRef: ElementRef;
10+
_elementRef: ElementRef<HTMLElement>;
1111
_noopAnimations: boolean;
1212
readonly _strokeCircumference: number;
1313
readonly _strokeDashOffset: number | null;
@@ -16,7 +16,7 @@ export declare class MatProgressSpinner extends _MatProgressSpinnerMixinBase imp
1616
mode: ProgressSpinnerMode;
1717
strokeWidth: number;
1818
value: number;
19-
constructor(_elementRef: ElementRef, platform: Platform, _document: any, animationMode?: string | undefined, defaults?: MatProgressSpinnerDefaultOptions | undefined);
19+
constructor(_elementRef: ElementRef<HTMLElement>, platform: Platform, _document: any, animationMode: string, defaults?: MatProgressSpinnerDefaultOptions);
2020
}
2121

2222
export declare class MatProgressSpinnerBase {
@@ -31,7 +31,7 @@ export interface MatProgressSpinnerDefaultOptions {
3131
}
3232

3333
export declare class MatSpinner extends MatProgressSpinner {
34-
constructor(elementRef: ElementRef, platform: Platform, document: any, animationMode?: string, defaults?: MatProgressSpinnerDefaultOptions);
34+
constructor(elementRef: ElementRef<HTMLElement>, platform: Platform, document: any, animationMode: string, defaults?: MatProgressSpinnerDefaultOptions);
3535
}
3636

3737
export declare type ProgressSpinnerMode = 'determinate' | 'indeterminate';

0 commit comments

Comments
 (0)