@@ -368,14 +368,24 @@ describe('MatSlideToggle without forms', () => {
368
368
. toBe ( 5 , 'Expected tabIndex property to have been set based on the native attribute' ) ;
369
369
} ) ) ;
370
370
371
- it ( 'should clear the tabindex from the host element' , fakeAsync ( ( ) => {
371
+ it ( 'should set the tabindex of the host element to -1 ' , fakeAsync ( ( ) => {
372
372
const fixture = TestBed . createComponent ( SlideToggleWithTabindexAttr ) ;
373
373
374
374
fixture . detectChanges ( ) ;
375
375
376
376
const slideToggle = fixture . debugElement . query ( By . directive ( MatSlideToggle ) ) . nativeElement ;
377
377
expect ( slideToggle . getAttribute ( 'tabindex' ) ) . toBe ( '-1' ) ;
378
378
} ) ) ;
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
+ } ) ) ;
379
389
} ) ;
380
390
381
391
describe ( 'custom action configuration' , ( ) => {
@@ -1119,10 +1129,10 @@ class SlideToggleWithFormControl {
1119
1129
formControl = new FormControl ( ) ;
1120
1130
}
1121
1131
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
+ }
1126
1136
1127
1137
@Component ( {
1128
1138
template : `<mat-slide-toggle>{{label}}</mat-slide-toggle>`
0 commit comments