diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index cfb4e41fd8..4c706af486 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -7,6 +7,7 @@ | aria-dpub-role-fallback | Ensures unsupported DPUB roles are only used on elements with implicit fallback roles | Moderate | cat.aria, wcag2a, wcag131 | true | | aria-hidden-body | Ensures aria-hidden='true' is not present on the document body. | Critical | cat.aria, wcag2a, wcag412 | true | | aria-hidden-focus | Ensures aria-hidden elements do not contain focusable elements | Serious | cat.name-role-value, wcag2a, wcag412, wcag131 | true | +| aria-input-field-label | Ensures every ARIA input field has an accessible name | Moderate, Serious | wcag2a, wcag412 | true | | aria-required-attr | Ensures elements with ARIA roles have all required ARIA attributes | Critical | cat.aria, wcag2a, wcag412 | true | | aria-required-children | Ensures elements with an ARIA role that require child roles contain them | Critical | cat.aria, wcag2a, wcag131 | true | | aria-required-parent | Ensures elements with an ARIA role that require parent roles are contained by them | Critical | cat.aria, wcag2a, wcag131 | true | diff --git a/lib/checks/aria/no-implicit-explicit-label.js b/lib/checks/aria/no-implicit-explicit-label.js new file mode 100644 index 0000000000..9c850d8689 --- /dev/null +++ b/lib/checks/aria/no-implicit-explicit-label.js @@ -0,0 +1,21 @@ +const { aria, text } = axe.commons; + +const role = aria.getRole(node, { noImplicit: true }); +this.data(role); + +const labelText = text.sanitize(text.labelText(virtualNode)).toLowerCase(); +const accText = text.sanitize(text.accessibleText(node)).toLowerCase(); + +if (!accText && !labelText) { + return false; +} + +if (!accText && labelText) { + return undefined; +} + +if (!accText.includes(labelText)) { + return undefined; +} + +return false; diff --git a/lib/checks/aria/no-implicit-explicit-label.json b/lib/checks/aria/no-implicit-explicit-label.json new file mode 100644 index 0000000000..4a5a9fc518 --- /dev/null +++ b/lib/checks/aria/no-implicit-explicit-label.json @@ -0,0 +1,11 @@ +{ + "id": "no-implicit-explicit-label", + "evaluate": "no-implicit-explicit-label.js", + "metadata": { + "impact": "moderate", + "messages": { + "pass": "There is no mismatch between a