Skip to content

Commit

Permalink
Fix bug in get-role
Browse files Browse the repository at this point in the history
  • Loading branch information
khiga8 committed Sep 26, 2023
1 parent 9159923 commit 19e4ba9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/utils/get-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function getRole(context, node) {
const explicitRole = getLiteralPropValue(getProp(node.attributes, 'role'))
if (explicitRole) {
return explicitRole
} else if (getProp(node.attributes, 'role')) { // If role is set to anything other than a literal prop

Check failure on line 49 in lib/utils/get-role.js

View workflow job for this annotation

GitHub Actions / build (14)

Insert `⏎···`

Check failure on line 49 in lib/utils/get-role.js

View workflow job for this annotation

GitHub Actions / build (16)

Insert `⏎···`

Check failure on line 49 in lib/utils/get-role.js

View workflow job for this annotation

GitHub Actions / build (18)

Insert `⏎···`

Check failure on line 49 in lib/utils/get-role.js

View workflow job for this annotation

GitHub Actions / build (16)

Insert `⏎···`

Check failure on line 49 in lib/utils/get-role.js

View workflow job for this annotation

GitHub Actions / build (18)

Insert `⏎···`
return undefined
}

// Assemble a key for looking-up the element’s role in the `elementRolesMap`
Expand Down
4 changes: 2 additions & 2 deletions tests/utils/get-role.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('getRole', function () {
})

it('returns undefined when role is set to non-literal expression', function () {
// <Box role={isNavigationOpen ? 'generic' : 'navigation'} />
const node = mockJSXOpeningElement('Box', [
// <div role={isNavigationOpen ? 'generic' : 'navigation'} />
const node = mockJSXOpeningElement('div', [
mockJSXConditionalAttribute('role', 'isNavigationOpen', 'generic', 'navigation'),
])
expect(getRole({}, node)).to.equal(undefined)
Expand Down

0 comments on commit 19e4ba9

Please sign in to comment.