File tree 2 files changed +16
-4
lines changed
2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -55,11 +55,13 @@ const NavItem = React.createClass({
55
55
56
56
if ( ! role && href === '#' ) {
57
57
linkProps . role = 'button' ;
58
+ } else if ( role === 'tab' ) {
59
+ linkProps [ 'aria-selected' ] = active ;
58
60
}
59
61
60
62
return (
61
63
< li { ...props } role = "presentation" className = { classNames ( props . className , classes ) } >
62
- < SafeAnchor { ...linkProps } aria-selected = { active } aria- controls= { ariaControls } >
64
+ < SafeAnchor { ...linkProps } aria-controls = { ariaControls } >
63
65
{ children }
64
66
</ SafeAnchor >
65
67
</ li >
Original file line number Diff line number Diff line change @@ -135,14 +135,24 @@ describe('NavItem', () => {
135
135
assert . ok ( linkElement . hasAttribute ( 'aria-controls' ) ) ;
136
136
} ) ;
137
137
138
- it ( 'Should add aria-selected to the link' , ( ) => {
138
+ it ( 'Should add aria-selected to the link when role is "tab" ' , ( ) => {
139
139
let instance = ReactTestUtils . renderIntoDocument (
140
- < NavItem active > Item content</ NavItem >
140
+ < NavItem role = "tab" active > Item content</ NavItem >
141
141
) ;
142
142
143
143
let linkElement = ReactTestUtils . findRenderedDOMComponentWithTag ( instance , 'a' ) ;
144
144
145
- assert . equal ( linkElement . getAttribute ( 'aria-selected' ) , 'true' ) ;
145
+ expect ( linkElement . getAttribute ( 'aria-selected' ) ) . to . equal ( 'true' ) ;
146
+ } ) ;
147
+
148
+ it ( 'Should not add aria-selected to the link when role is not "tab"' , ( ) => {
149
+ let instance = ReactTestUtils . renderIntoDocument (
150
+ < NavItem role = "button" active > Item content</ NavItem >
151
+ ) ;
152
+
153
+ let linkElement = ReactTestUtils . findRenderedDOMComponentWithTag ( instance , 'a' ) ;
154
+
155
+ expect ( linkElement . getAttribute ( 'aria-selected' ) ) . to . not . exist ;
146
156
} ) ;
147
157
148
158
it ( 'Should pass role down' , ( ) => {
You can’t perform that action at this time.
0 commit comments