@@ -368,14 +368,24 @@ describe('MatSlideToggle without forms', () => {
368368 . toBe ( 5 , 'Expected tabIndex property to have been set based on the native attribute' ) ;
369369 } ) ) ;
370370
371- it ( 'should clear the tabindex from the host element' , fakeAsync ( ( ) => {
371+ it ( 'should set the tabindex of the host element to -1 ' , fakeAsync ( ( ) => {
372372 const fixture = TestBed . createComponent ( SlideToggleWithTabindexAttr ) ;
373373
374374 fixture . detectChanges ( ) ;
375375
376376 const slideToggle = fixture . debugElement . query ( By . directive ( MatSlideToggle ) ) . nativeElement ;
377377 expect ( slideToggle . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
378378 } ) ) ;
379+
380+ it ( 'should remove the tabindex from the host element when disabled' , fakeAsync ( ( ) => {
381+ const fixture = TestBed . createComponent ( SlideToggleWithTabindexAttr ) ;
382+
383+ fixture . componentInstance . disabled = true ;
384+ fixture . detectChanges ( ) ;
385+
386+ const slideToggle = fixture . debugElement . query ( By . directive ( MatSlideToggle ) ) . nativeElement ;
387+ expect ( slideToggle . hasAttribute ( 'tabindex' ) ) . toBe ( false ) ;
388+ } ) ) ;
379389 } ) ;
380390
381391 describe ( 'custom action configuration' , ( ) => {
@@ -1119,10 +1129,10 @@ class SlideToggleWithFormControl {
11191129 formControl = new FormControl ( ) ;
11201130}
11211131
1122- @Component ( {
1123- template : `<mat-slide-toggle tabindex="5"></mat-slide-toggle>`
1124- } )
1125- class SlideToggleWithTabindexAttr { }
1132+ @Component ( { template : `<mat-slide-toggle tabindex="5" [disabled]="disabled"></mat-slide-toggle>` } )
1133+ class SlideToggleWithTabindexAttr {
1134+ disabled = false ;
1135+ }
11261136
11271137@Component ( {
11281138 template : `<mat-slide-toggle>{{label}}</mat-slide-toggle>`
0 commit comments