Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 19e4ba9

Browse filesBrowse files
committed
Fix bug in get-role
1 parent 9159923 commit 19e4ba9
Copy full SHA for 19e4ba9

File tree

Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed

‎lib/utils/get-role.js

Copy file name to clipboardExpand all lines: lib/utils/get-role.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function getRole(context, node) {
4646
const explicitRole = getLiteralPropValue(getProp(node.attributes, 'role'))
4747
if (explicitRole) {
4848
return explicitRole
49+
} else if (getProp(node.attributes, 'role')) { // If role is set to anything other than a literal prop
50+
return undefined
4951
}
5052

5153
// Assemble a key for looking-up the element’s role in the `elementRolesMap`

‎tests/utils/get-role.js

Copy file name to clipboardExpand all lines: tests/utils/get-role.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ describe('getRole', function () {
1313
})
1414

1515
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', [
1818
mockJSXConditionalAttribute('role', 'isNavigationOpen', 'generic', 'navigation'),
1919
])
2020
expect(getRole({}, node)).to.equal(undefined)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.