From ce20fbff53e5e6675bfd93279f7ee3bd6cb3a263 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 7 Jun 2019 09:29:38 -0400 Subject: [PATCH] feat(rules): split button name rule into button only and button input rules (#1615) --- doc/rule-descriptions.md | 3 ++- lib/rules/button-name.json | 6 ++--- lib/rules/input-button-name.json | 26 +++++++++++++++++++ .../rules/button-name/button-name.html | 2 +- .../rules/button-name/button-name.json | 12 +++------ .../input-button-name/input-button-name.html | 3 +++ .../input-button-name/input-button-name.json | 7 +++-- 7 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 lib/rules/input-button-name.json diff --git a/doc/rule-descriptions.md b/doc/rule-descriptions.md index 831c1cdd5e..0132bfb687 100644 --- a/doc/rule-descriptions.md +++ b/doc/rule-descriptions.md @@ -19,7 +19,7 @@ | autocomplete-valid | Ensure the autocomplete attribute is correct and suitable for the form field | Serious | cat.forms, wcag21aa, wcag135 | true | | avoid-inline-spacing | Ensure that text spacing set through style attributes can be adjusted with custom stylesheets | Serious | wcag21, wcag1412 | true | | blink | Ensures <blink> elements are not used | Serious | cat.time-and-media, wcag2a, wcag222, section508, section508.22.j | true | -| button-name | Ensures buttons have discernible text | Serious, Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | true | +| button-name | Ensures buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | true | | bypass | Ensures each page has at least one mechanism for a user to bypass navigation and jump straight to the content | Serious | cat.keyboard, wcag2a, wcag241, section508, section508.22.o | true | | checkboxgroup | Ensures related <input type="checkbox"> elements have a group and that the group designation is consistent | Critical | cat.forms, best-practice | true | | color-contrast | Ensures the contrast between foreground and background colors meets WCAG 2 AA contrast ratio thresholds | Serious | cat.color, wcag2aa, wcag143 | true | @@ -43,6 +43,7 @@ | html-xml-lang-mismatch | Ensure that HTML elements with both valid lang and xml:lang attributes agree on the base language of the page | Moderate | cat.language, wcag2a, wcag311 | true | | image-alt | Ensures <img> elements have alternate text or a role of none or presentation | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | image-redundant-alt | Ensure button and link text is not repeated as image alternative | Minor | cat.text-alternatives, best-practice | true | +| input-button-name | Ensures input buttons have discernible text | Critical | cat.name-role-value, wcag2a, wcag412, section508, section508.22.a | true | | input-image-alt | Ensures <input type="image"> elements have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true | | label-content-name-mismatch | Ensures that elements labelled through their content must have their visible text as part of their accessible name | Serious | wcag21a, wcag253, experimental | true | | label-title-only | Ensures that every form element is not solely labeled using the title or aria-describedby attributes | Serious | cat.forms, best-practice | true | diff --git a/lib/rules/button-name.json b/lib/rules/button-name.json index e2da97a2ef..826a3da068 100644 --- a/lib/rules/button-name.json +++ b/lib/rules/button-name.json @@ -1,6 +1,6 @@ { "id": "button-name", - "selector": "button, [role=\"button\"], input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"]", + "selector": "button, [role=\"button\"]", "tags": [ "cat.name-role-value", "wcag2a", @@ -14,8 +14,6 @@ }, "all": [], "any": [ - "non-empty-if-present", - "non-empty-value", "button-has-visible-text", "aria-label", "aria-labelledby", @@ -23,5 +21,5 @@ "role-none", "non-empty-title" ], - "none": ["focusable-no-name"] + "none": [] } diff --git a/lib/rules/input-button-name.json b/lib/rules/input-button-name.json new file mode 100644 index 0000000000..2e75cb6926 --- /dev/null +++ b/lib/rules/input-button-name.json @@ -0,0 +1,26 @@ +{ + "id": "input-button-name", + "selector": "input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"]", + "tags": [ + "cat.name-role-value", + "wcag2a", + "wcag412", + "section508", + "section508.22.a" + ], + "metadata": { + "description": "Ensures input buttons have discernible text", + "help": "Input buttons must have discernible text" + }, + "all": [], + "any": [ + "non-empty-if-present", + "non-empty-value", + "aria-label", + "aria-labelledby", + "role-presentation", + "role-none", + "non-empty-title" + ], + "none": [] +} diff --git a/test/integration/rules/button-name/button-name.html b/test/integration/rules/button-name/button-name.html index 57af2b722b..b95941611f 100644 --- a/test/integration/rules/button-name/button-name.html +++ b/test/integration/rules/button-name/button-name.html @@ -10,4 +10,4 @@
- + diff --git a/test/integration/rules/button-name/button-name.json b/test/integration/rules/button-name/button-name.json index 3f438646bb..df76873b53 100644 --- a/test/integration/rules/button-name/button-name.json +++ b/test/integration/rules/button-name/button-name.json @@ -6,14 +6,8 @@ ["#val"], ["#alempty"], ["#albmissing"], - ["#albempty"] + ["#albempty"], + ["#buttonvalue"] ], - "passes": [ - ["#text"], - ["#al"], - ["#alb"], - ["#combo"], - ["#buttonTitle"], - ["#inputTitle"] - ] + "passes": [["#text"], ["#al"], ["#alb"], ["#combo"], ["#buttonTitle"]] } diff --git a/test/integration/rules/input-button-name/input-button-name.html b/test/integration/rules/input-button-name/input-button-name.html index e2b8fa54fb..6fa0529d72 100644 --- a/test/integration/rules/input-button-name/input-button-name.html +++ b/test/integration/rules/input-button-name/input-button-name.html @@ -15,4 +15,7 @@ + + + diff --git a/test/integration/rules/input-button-name/input-button-name.json b/test/integration/rules/input-button-name/input-button-name.json index 2342d91c68..9227368afd 100644 --- a/test/integration/rules/input-button-name/input-button-name.json +++ b/test/integration/rules/input-button-name/input-button-name.json @@ -1,6 +1,6 @@ { "description": "input-button-name test", - "rule": "button-name", + "rule": "input-button-name", "violations": [ ["#fail1"], ["#fail2"], @@ -17,6 +17,9 @@ ["#pass5"], ["#pass6"], ["#pass7"], - ["#pass8"] + ["#pass8"], + ["#pass9"], + ["#pass10"], + ["#pass11"] ] }