diff --git a/lib/utils/get-role.js b/lib/utils/get-role.js index 8fea9178..54654ee8 100644 --- a/lib/utils/get-role.js +++ b/lib/utils/get-role.js @@ -46,6 +46,9 @@ 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 + return undefined } // Assemble a key for looking-up the element’s role in the `elementRolesMap` diff --git a/tests/a11y-role-supports-aria-props.js b/tests/a11y-role-supports-aria-props.js index a367e454..424c363a 100644 --- a/tests/a11y-role-supports-aria-props.js +++ b/tests/a11y-role-supports-aria-props.js @@ -29,6 +29,18 @@ function getErrorMessage(attribute, role) { ruleTester.run('a11y-role-supports-aria-props', rule, { valid: [ + { + code: ` +
+ {children} +
`, + }, {code: ''}, {code: '
'}, {code: '
'}, diff --git a/tests/utils/get-role.js b/tests/utils/get-role.js index c8d2aa5b..86c3bdc8 100644 --- a/tests/utils/get-role.js +++ b/tests/utils/get-role.js @@ -13,8 +13,8 @@ describe('getRole', function () { }) it('returns undefined when role is set to non-literal expression', function () { - // - const node = mockJSXOpeningElement('Box', [ + //
+ const node = mockJSXOpeningElement('div', [ mockJSXConditionalAttribute('role', 'isNavigationOpen', 'generic', 'navigation'), ]) expect(getRole({}, node)).to.equal(undefined) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy