From 5607f4a1cb1ef92220e19d961e26444717fe661a Mon Sep 17 00:00:00 2001 From: Wilco Fiers Date: Thu, 24 Oct 2024 13:17:05 +0200 Subject: [PATCH] fix(aria-required-children): never fail if given aria-busy=true --- lib/checks/aria/aria-required-children-evaluate.js | 10 +++++----- test/checks/aria/required-children.js | 8 +++----- .../aria-required-children/aria-required-children.html | 4 ++-- .../aria-required-children/aria-required-children.json | 6 +++--- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/checks/aria/aria-required-children-evaluate.js b/lib/checks/aria/aria-required-children-evaluate.js index 1e7512d960..7094164316 100644 --- a/lib/checks/aria/aria-required-children-evaluate.js +++ b/lib/checks/aria/aria-required-children-evaluate.js @@ -34,6 +34,11 @@ export default function ariaRequiredChildrenEvaluate( return true; } + if (virtualNode.attr('aria-busy') === 'true') { + this.data({ messageKey: 'aria-busy' }); + return true; + } + const ownedRoles = getOwnedRoles(virtualNode, required); const unallowed = ownedRoles.filter( ({ role, vNode }) => vNode.props.nodeType === 1 && !required.includes(role) @@ -55,11 +60,6 @@ export default function ariaRequiredChildrenEvaluate( return true; } - if (virtualNode.attr('aria-busy') === 'true') { - this.data({ messageKey: 'aria-busy' }); - return true; - } - this.data(required); // Only review empty nodes when a node is both empty and does not have an aria-owns relationship diff --git a/test/checks/aria/required-children.js b/test/checks/aria/required-children.js index faf68eb714..b3eaf04db5 100644 --- a/test/checks/aria/required-children.js +++ b/test/checks/aria/required-children.js @@ -146,15 +146,13 @@ describe('aria-required-children', () => { }); }); - it('should fail list with an unallowed child, even if aria-busy="true"', () => { + it('should pass list with an unallowed child, if given aria-busy="true"', () => { const params = checkSetup(`
`); - assert.isFalse(requiredChildrenCheck.apply(checkContext, params)); - + assert.isTrue(requiredChildrenCheck.apply(checkContext, params)); assert.deepEqual(checkContext._data, { - messageKey: 'unallowed', - values: '[role=tabpanel]' + messageKey: 'aria-busy' }); }); diff --git a/test/integration/rules/aria-required-children/aria-required-children.html b/test/integration/rules/aria-required-children/aria-required-children.html index af5b16d858..5c7f09274b 100644 --- a/test/integration/rules/aria-required-children/aria-required-children.html +++ b/test/integration/rules/aria-required-children/aria-required-children.html @@ -114,8 +114,8 @@
-
-
unallowed role
+
+
ignored role
diff --git a/test/integration/rules/aria-required-children/aria-required-children.json b/test/integration/rules/aria-required-children/aria-required-children.json index 4b32bb9c7b..714d8469fd 100644 --- a/test/integration/rules/aria-required-children/aria-required-children.json +++ b/test/integration/rules/aria-required-children/aria-required-children.json @@ -13,8 +13,7 @@ ["#fail9"], ["#fail10"], ["#fail11"], - ["#fail12"], - ["#fail13"] + ["#fail12"] ], "passes": [ ["#pass1"], @@ -35,7 +34,8 @@ ["#pass16"], ["#pass17"], ["#pass18"], - ["#pass19"] + ["#pass19"], + ["#pass20"] ], "incomplete": [ ["#incomplete1"],