File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,23 @@ describe('MatTabNavBar', () => {
66
66
fixture . detectChanges ( ) ;
67
67
expect ( tabLinkElements [ 0 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeFalsy ( ) ;
68
68
expect ( tabLinkElements [ 1 ] . classList . contains ( 'mat-tab-label-active' ) ) . toBeTruthy ( ) ;
69
+ } ) ;
70
+
71
+ it ( 'should toggle aria-selected based on active state' , ( ) => {
72
+ let tabLink1 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 0 ] ;
73
+ let tabLink2 = fixture . debugElement . queryAll ( By . css ( 'a' ) ) [ 1 ] ;
74
+ const tabLinkElements = fixture . debugElement . queryAll ( By . css ( 'a' ) )
75
+ . map ( tabLinkDebugEl => tabLinkDebugEl . nativeElement ) ;
69
76
77
+ tabLink1 . nativeElement . click ( ) ;
78
+ fixture . detectChanges ( ) ;
79
+ expect ( tabLinkElements [ 0 ] . getAttribute ( 'aria-selected' ) ) . toEqual ( 'true' ) ;
80
+ expect ( tabLinkElements [ 1 ] . getAttribute ( 'aria-selected' ) ) . toEqual ( 'false' ) ;
81
+
82
+ tabLink2 . nativeElement . click ( ) ;
83
+ fixture . detectChanges ( ) ;
84
+ expect ( tabLinkElements [ 0 ] . getAttribute ( 'aria-selected' ) ) . toEqual ( 'false' ) ;
85
+ expect ( tabLinkElements [ 1 ] . getAttribute ( 'aria-selected' ) ) . toEqual ( 'true' ) ;
70
86
} ) ;
71
87
72
88
it ( 'should add the disabled class if disabled' , ( ) => {
Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ export const _MatTabLinkMixinBase =
173
173
host : {
174
174
'class' : 'mat-tab-link' ,
175
175
'[attr.aria-disabled]' : 'disabled.toString()' ,
176
+ '[attr.aria-selected]' : 'active' ,
176
177
'[attr.tabIndex]' : 'tabIndex' ,
177
178
'[class.mat-tab-disabled]' : 'disabled' ,
178
179
'[class.mat-tab-label-active]' : 'active' ,
You can’t perform that action at this time.
0 commit comments