From 9159923f403c205e65de0b07405ed85cce85d9ce Mon Sep 17 00:00:00 2001
From: Kate Higa <16447748+khiga8@users.noreply.github.com>
Date: Tue, 26 Sep 2023 10:23:51 -0400
Subject: [PATCH 1/3] Add failing testcase
---
tests/a11y-role-supports-aria-props.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
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: ''},
From 19e4ba9d5bad2e75ff970026abd70b050bb1e183 Mon Sep 17 00:00:00 2001
From: Kate Higa <16447748+khiga8@users.noreply.github.com>
Date: Tue, 26 Sep 2023 10:34:38 -0400
Subject: [PATCH 2/3] Fix bug in get-role
---
lib/utils/get-role.js | 2 ++
tests/utils/get-role.js | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/utils/get-role.js b/lib/utils/get-role.js
index 8fea9178..35e63308 100644
--- a/lib/utils/get-role.js
+++ b/lib/utils/get-role.js
@@ -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
+ return undefined
}
// Assemble a key for looking-up the element’s role in the `elementRolesMap`
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)
From 3ecb9f102f266806dcfa3c7b5298537206b8fabf Mon Sep 17 00:00:00 2001
From: Kate Higa <16447748+khiga8@users.noreply.github.com>
Date: Tue, 26 Sep 2023 10:37:33 -0400
Subject: [PATCH 3/3] Run prettier
---
lib/utils/get-role.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/utils/get-role.js b/lib/utils/get-role.js
index 35e63308..54654ee8 100644
--- a/lib/utils/get-role.js
+++ b/lib/utils/get-role.js
@@ -46,7 +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
+ } else if (getProp(node.attributes, 'role')) {
+ // If role is set to anything other than a literal prop
return 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