From 69a9c3b08e94901cc6e8376c6aeca60fb6ac197b Mon Sep 17 00:00:00 2001 From: Jey Date: Thu, 6 Jun 2019 08:01:35 -0400 Subject: [PATCH] feat(rule): New aria-toggle-field-label rule (#1450) --- doc/rule-descriptions.md | 1 + lib/rules/aria-toggle-field-label.json | 18 +++++ .../aria-toggle-field-label.html | 80 +++++++++++++++++++ .../aria-toggle-field-label.json | 7 ++ 4 files changed, 106 insertions(+) create mode 100644 lib/rules/aria-toggle-field-label.json create mode 100644 test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.html create mode 100644 test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.json diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 4c706af486..831c1cdd5e 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -12,6 +12,7 @@ | 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 | | aria-roles | Ensures all elements with a role attribute use a valid value | Serious, Critical | cat.aria, wcag2a, wcag412 | true | +| aria-toggle-field-label | Ensures every ARIA toggle field has an accessible name | Moderate, Serious | wcag2a, wcag412 | true | | aria-valid-attr-value | Ensures all ARIA attributes have valid values | Critical | cat.aria, wcag2a, wcag412 | true | | aria-valid-attr | Ensures attributes that begin with aria- are valid ARIA attributes | Critical | cat.aria, wcag2a, wcag412 | true | | audio-caption | Ensures <audio> elements have captions | Critical | cat.time-and-media, wcag2a, wcag121, section508, section508.22.a | false | diff --git a/lib/rules/aria-toggle-field-label.json b/lib/rules/aria-toggle-field-label.json new file mode 100644 index 0000000000..e2171a9c7b --- /dev/null +++ b/lib/rules/aria-toggle-field-label.json @@ -0,0 +1,18 @@ +{ + "id": "aria-toggle-field-label", + "selector": "[role=\"checkbox\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"radio\"], [role=\"switch\"]", + "matches": "aria-form-field-label-matches.js", + "tags": ["wcag2a", "wcag412"], + "metadata": { + "description": "Ensures every ARIA toggle field has an accessible name", + "help": "ARIA toggle fields have an accessible name" + }, + "all": [], + "any": [ + "aria-label", + "aria-labelledby", + "non-empty-title", + "has-visible-text" + ], + "none": ["no-implicit-explicit-label"] +} diff --git a/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.html b/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.html new file mode 100644 index 0000000000..45baa124f8 --- /dev/null +++ b/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.html @@ -0,0 +1,80 @@ + + + + + + +

Sans-serif

+ + +
+ +
+ +
+ off + on +
+ + + + + + + + + +
+ +
+ +
+ + +
+ + + + + + + + + + diff --git a/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.json b/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.json new file mode 100644 index 0000000000..251fc0243c --- /dev/null +++ b/test/integration/rules/aria-toggle-field-label/aria-toggle-field-label.json @@ -0,0 +1,7 @@ +{ + "description": "aria-toggle-field-label test", + "rule": "aria-toggle-field-label", + "passes": [["#pass1"], ["#pass2"], ["#pass3"], ["#pass4"], ["#pass5"]], + "violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"], ["#fail5"]], + "incomplete": [["#canttell1"], ["#canttell2"]] +}