Skip to content

Commit f525042

Browse files
chutchins25WilcoFiers
authored andcommitted
fix(existing-rule): aria-busy now shows an error message for a use with unallowed children (#5017)
Updated existing rule for aria-required-children for cases where the aria-busy attribute is used. This now will show the user a specific error message regarding aria-busy with unallowed children instead of the one for used for other cases using unallowed children. Replaces PR: [5011](#5011) Closes: #4626
1 parent 5ac6640 commit f525042

4 files changed

Lines changed: 10 additions & 5 deletions

File tree

lib/checks/aria/aria-required-children-evaluate.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ export default function ariaRequiredChildrenEvaluate(
4141

4242
if (unallowed.length) {
4343
this.relatedNodes(unallowed.map(({ vNode }) => vNode));
44+
const messageKey =
45+
virtualNode.attr('aria-busy') === 'true' ? 'aria-busy-fail' : 'unallowed';
46+
4447
this.data({
45-
messageKey: 'unallowed',
48+
messageKey,
4649
values: unallowed
4750
.map(({ vNode, attr }) => getUnallowedSelector(vNode, attr))
4851
.filter((selector, index, array) => array.indexOf(selector) === index)

lib/checks/aria/aria-required-children.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"fail": {
2828
"singular": "Required ARIA child role not present: ${data.values}",
2929
"plural": "Required ARIA children role not present: ${data.values}",
30-
"unallowed": "Element has children which are not allowed: ${data.values}"
30+
"unallowed": "Element has children which are not allowed: ${data.values}",
31+
"aria-busy-fail": "Element has children which are not allowed: ${data.values}; Having aria-busy=\"true\" does not allow children with roles that are not allowed"
3132
},
3233
"incomplete": {
3334
"singular": "Expecting ARIA child role to be added: ${data.values}",

locales/_template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,8 @@
509509
"fail": {
510510
"singular": "Required ARIA child role not present: ${data.values}",
511511
"plural": "Required ARIA children role not present: ${data.values}",
512-
"unallowed": "Element has children which are not allowed: ${data.values}"
512+
"unallowed": "Element has children which are not allowed: ${data.values}",
513+
"aria-busy-fail": "Element has children which are not allowed: ${data.values}; Having aria-busy=\"true\" does not allow children with roles that are not allowed"
513514
},
514515
"incomplete": {
515516
"singular": "Expecting ARIA child role to be added: ${data.values}",

test/checks/aria/required-children.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ describe('aria-required-children', () => {
146146
});
147147
});
148148

149-
it('should fail list with an unallowed child, even if aria-busy="true"', () => {
149+
it('should fail list with an unallowed child but show a custom message, even if aria-busy="true"', () => {
150150
const params = checkSetup(`
151151
<div id="target" role="list" aria-busy="true"><div role="tabpanel"></div></div>
152152
`);
153153
assert.isFalse(requiredChildrenCheck.apply(checkContext, params));
154154

155155
assert.deepEqual(checkContext._data, {
156-
messageKey: 'unallowed',
156+
messageKey: 'aria-busy-fail',
157157
values: '[role=tabpanel]'
158158
});
159159
});

0 commit comments

Comments
 (0)