Skip to content

Commit

Permalink
fix(aria-required-children): never fail if given aria-busy=true
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Oct 24, 2024
1 parent 61dd5e3 commit 5607f4a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
10 changes: 5 additions & 5 deletions lib/checks/aria/aria-required-children-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions test/checks/aria/required-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
<div id="target" role="list" aria-busy="true"><div role="tabpanel"></div></div>
`);
assert.isFalse(requiredChildrenCheck.apply(checkContext, params));

assert.isTrue(requiredChildrenCheck.apply(checkContext, params));
assert.deepEqual(checkContext._data, {
messageKey: 'unallowed',
values: '[role=tabpanel]'
messageKey: 'aria-busy'
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@
<div aria-busy="true"></div>
</div>

<div role="list" id="fail13" aria-busy="true">
<div role="alert">unallowed role</div>
<div role="list" id="pass20" aria-busy="true">
<div role="alert">ignored role</div>
</div>

<div role="doc-bibliography" id="inapplicable1"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
["#fail9"],
["#fail10"],
["#fail11"],
["#fail12"],
["#fail13"]
["#fail12"]
],
"passes": [
["#pass1"],
Expand All @@ -35,7 +34,8 @@
["#pass16"],
["#pass17"],
["#pass18"],
["#pass19"]
["#pass19"],
["#pass20"]
],
"incomplete": [
["#incomplete1"],
Expand Down

0 comments on commit 5607f4a

Please sign in to comment.