@@ -706,6 +706,7 @@ export class MatSlider
706706
707707 ngAfterViewInit ( ) {
708708 if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
709+ _validateThumbs ( this . _isRange ( ) , this . _getThumb ( Thumb . START ) , this . _getThumb ( Thumb . END ) ) ;
709710 _validateInputs (
710711 this . _isRange ( ) ,
711712 this . _getInputElement ( Thumb . START ) ,
@@ -1202,25 +1203,28 @@ class SliderAdapter implements MDCSliderAdapter {
12021203 } ;
12031204}
12041205
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. */
12081207function _validateInputs (
12091208 isRange : boolean ,
12101209 startInputElement : HTMLInputElement ,
12111210 endInputElement : HTMLInputElement ,
12121211) : 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 ( ) ;
12241228 }
12251229}
12261230
0 commit comments