@@ -706,6 +706,7 @@ export class MatSlider
706
706
707
707
ngAfterViewInit ( ) {
708
708
if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
709
+ _validateThumbs ( this . _isRange ( ) , this . _getThumb ( Thumb . START ) , this . _getThumb ( Thumb . END ) ) ;
709
710
_validateInputs (
710
711
this . _isRange ( ) ,
711
712
this . _getInputElement ( Thumb . START ) ,
@@ -1202,25 +1203,28 @@ class SliderAdapter implements MDCSliderAdapter {
1202
1203
} ;
1203
1204
}
1204
1205
1205
- /**
1206
- * Ensures that there is not an invalid configuration for the slider thumb inputs.
1207
- */
1206
+ /** Ensures that there is not an invalid configuration for the slider thumb inputs. */
1208
1207
function _validateInputs (
1209
1208
isRange : boolean ,
1210
1209
startInputElement : HTMLInputElement ,
1211
1210
endInputElement : HTMLInputElement ,
1212
1211
) : void {
1213
- if ( isRange ) {
1214
- if ( ! startInputElement . hasAttribute ( 'matSliderStartThumb' ) ) {
1215
- _throwInvalidInputConfigurationError ( ) ;
1216
- }
1217
- if ( ! endInputElement . hasAttribute ( 'matSliderEndThumb' ) ) {
1218
- _throwInvalidInputConfigurationError ( ) ;
1219
- }
1220
- } else {
1221
- if ( ! endInputElement . hasAttribute ( 'matSliderThumb' ) ) {
1222
- _throwInvalidInputConfigurationError ( ) ;
1223
- }
1212
+ const startValid = ! isRange || startInputElement . hasAttribute ( 'matSliderStartThumb' ) ;
1213
+ const endValid = endInputElement . hasAttribute ( isRange ? 'matSliderEndThumb' : 'matSliderThumb' ) ;
1214
+
1215
+ if ( ! startValid || ! endValid ) {
1216
+ _throwInvalidInputConfigurationError ( ) ;
1217
+ }
1218
+ }
1219
+
1220
+ /** Validates that the slider has the correct set of thumbs. */
1221
+ function _validateThumbs (
1222
+ isRange : boolean ,
1223
+ start : MatSliderVisualThumb | undefined ,
1224
+ end : MatSliderVisualThumb | undefined ,
1225
+ ) : void {
1226
+ if ( ! end && ( ! isRange || ! start ) ) {
1227
+ _throwInvalidInputConfigurationError ( ) ;
1224
1228
}
1225
1229
}
1226
1230
0 commit comments