File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +4
-2
lines changed
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ function getRole(context, node) {
46
46
const explicitRole = getLiteralPropValue ( getProp ( node . attributes , 'role' ) )
47
47
if ( explicitRole ) {
48
48
return explicitRole
49
+ } else if ( getProp ( node . attributes , 'role' ) ) { // If role is set to anything other than a literal prop
50
+ return undefined
49
51
}
50
52
51
53
// Assemble a key for looking-up the element’s role in the `elementRolesMap`
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ describe('getRole', function () {
13
13
} )
14
14
15
15
it ( 'returns undefined when role is set to non-literal expression' , function ( ) {
16
- // <Box role={isNavigationOpen ? 'generic' : 'navigation'} />
17
- const node = mockJSXOpeningElement ( 'Box ' , [
16
+ // <div role={isNavigationOpen ? 'generic' : 'navigation'} />
17
+ const node = mockJSXOpeningElement ( 'div ' , [
18
18
mockJSXConditionalAttribute ( 'role' , 'isNavigationOpen' , 'generic' , 'navigation' ) ,
19
19
] )
20
20
expect ( getRole ( { } , node ) ) . to . equal ( undefined )
You can’t perform that action at this time.
0 commit comments