@@ -21,6 +21,7 @@ import {
2121import { CanColor , mixinColor } from '@angular/material/core' ;
2222import { Platform } from '@angular/cdk/platform' ;
2323import { DOCUMENT } from '@angular/common' ;
24+ import { coerceNumberProperty } from '@angular/cdk/coercion' ;
2425
2526/** Possible mode for a progress spinner. */
2627export type ProgressSpinnerMode = 'determinate' | 'indeterminate' ;
@@ -86,6 +87,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
8687 private _value : number ;
8788 private readonly _baseSize = 100 ;
8889 private readonly _baseStrokeWidth = 10 ;
90+ private _strokeWidth = 10 ;
8991 private _fallbackAnimation = false ;
9092
9193 /** The width and height of the host element. Will grow with stroke width. **/
@@ -102,14 +104,23 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
102104 get diameter ( ) : number {
103105 return this . _diameter ;
104106 }
105-
106107 set diameter ( size : number ) {
107- this . _setDiameterAndInitStyles ( size ) ;
108+ this . _diameter = coerceNumberProperty ( size ) ;
109+
110+ if ( ! this . _fallbackAnimation && ! MatProgressSpinner . diameters . has ( this . _diameter ) ) {
111+ this . _attachStyleNode ( ) ;
112+ }
108113 }
109- _diameter = this . _baseSize ;
114+ private _diameter = this . _baseSize ;
110115
111116 /** Stroke width of the progress spinner. */
112- @Input ( ) strokeWidth : number = 10 ;
117+ @Input ( )
118+ get strokeWidth ( ) : number {
119+ return this . _strokeWidth ;
120+ }
121+ set strokeWidth ( value : number ) {
122+ this . _strokeWidth = coerceNumberProperty ( value ) ;
123+ }
113124
114125 /** Mode of the progress circle */
115126 @Input ( ) mode : ProgressSpinnerMode = 'determinate' ;
@@ -121,7 +132,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
121132 }
122133 set value ( newValue : number ) {
123134 if ( newValue != null && this . mode === 'determinate' ) {
124- this . _value = Math . max ( 0 , Math . min ( 100 , newValue ) ) ;
135+ this . _value = Math . max ( 0 , Math . min ( 100 , coerceNumberProperty ( newValue ) ) ) ;
125136 }
126137 }
127138
@@ -181,14 +192,6 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
181192 return this . strokeWidth / this . _elementSize * 100 ;
182193 }
183194
184- /** Sets the diameter and adds diameter-specific styles if necessary. */
185- private _setDiameterAndInitStyles ( size : number ) : void {
186- this . _diameter = size ;
187- if ( ! MatProgressSpinner . diameters . has ( this . diameter ) && ! this . _fallbackAnimation ) {
188- this . _attachStyleNode ( ) ;
189- }
190- }
191-
192195 /** Dynamically generates a style tag containing the correct animation for this diameter. */
193196 private _attachStyleNode ( ) : void {
194197 let styleTag = MatProgressSpinner . styleTag ;
0 commit comments