Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aria-allowed-attr): no inconsistent aria-checked on HTML checkboxes #3895

Merged
merged 9 commits into from
May 2, 2023
Prev Previous commit
Next Next commit
Cleanup / docs work
  • Loading branch information
WilcoFiers committed Jan 26, 2023
commit 0e43e43e8b628a5614f47d906cd8fd42b8f9827e
6 changes: 5 additions & 1 deletion doc/check-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ All checks allow these global options:

### aria-allowed-attr

Previously supported properties `validTreeRowAttrs` is no longer available. `invalidTableRowAttrs` from [aria-conditional-attr](#aria-conditional-attr) instead.

### aria-conditional-attr

<table>
<thead>
<tr>
Expand All @@ -218,7 +222,7 @@ All checks allow these global options:
<tbody>
<tr>
<td>
<code>validTreeRowAttrs</code>
<code>invalidTableRowAttrs</code>
</td>
<td align="left">
<pre lang=js><code>[
Expand Down
11 changes: 3 additions & 8 deletions lib/checks/aria/aria-allowed-attr-evaluate.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ export default function ariaAllowedAttrEvaluate(node, options, virtualNode) {
allowed = uniqueArray(options[role].concat(allowed));
}

// Unknown ARIA attributes are tested in aria-valid-attr
for (const attrName of virtualNode.attrNames) {
if (!validateAttr(attrName)) {
continue; // Unknown ARIA attributes are tested in aria-valid-attr
}
if (!allowed.includes(attrName)) {
if (validateAttr(attrName) && !allowed.includes(attrName)) {
invalid.push(attrName);
}
}
Expand All @@ -51,13 +49,10 @@ export default function ariaAllowedAttrEvaluate(node, options, virtualNode) {
}

this.data(
invalid.map(attrName => {
return attrName + '="' + virtualNode.attr(attrName) + '"';
})
invalid.map(attrName => attrName + '="' + virtualNode.attr(attrName) + '"')
);

if (!role && !isHtmlElement(virtualNode) && !isFocusable(virtualNode)) {
// TODO: Some message thing
return undefined;
}
return false;
Expand Down
9 changes: 9 additions & 0 deletions locales/_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,15 @@
"pass": "Element has an aria-busy attribute",
"fail": "Element has no aria-busy=\"true\" attribute"
},
"aria-conditional-attr": {
"pass": "ARIA attribute is allowed",
"fail": {
"checkbox": "The aria-checked attribute must be removed, or be consistent with the native checked state",
"checkboxMixed": "aria-checked=\"mixed\" cannot be used on an native HTML checkbox",
"rowSingular": "This row attribute is supported with treegrid, but not ${data.ownerRole}: ${data.invalidAttrs}",
"rowPlural": "These row attributes are supported with treegrid, but not ${data.ownerRole}: ${data.invalidAttrs}"
}
},
"aria-errormessage": {
"pass": "aria-errormessage exists and references elements visible to screen readers that use a supported aria-errormessage technique",
"fail": {
Expand Down