Skip to content

Commit

Permalink
feat(rules): split button name rule into button only and button input…
Browse files Browse the repository at this point in the history
… rules (#1615)
  • Loading branch information
scurker committed Jun 7, 2019
1 parent 14ed6dc commit ce20fbf
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 17 deletions.
3 changes: 2 additions & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down
6 changes: 2 additions & 4 deletions lib/rules/button-name.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -14,14 +14,12 @@
},
"all": [],
"any": [
"non-empty-if-present",
"non-empty-value",
"button-has-visible-text",
"aria-label",
"aria-labelledby",
"role-presentation",
"role-none",
"non-empty-title"
],
"none": ["focusable-no-name"]
"none": []
}
26 changes: 26 additions & 0 deletions lib/rules/input-button-name.json
Original file line number Diff line number Diff line change
@@ -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": []
}
2 changes: 1 addition & 1 deletion test/integration/rules/button-name/button-name.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
<div id="emptydiv"></div>
<button id="combo" aria-label="Aria Name">Name</button>
<button id="buttonTitle" title="Title"></button>
<input id="inputTitle" title="Search" type="button" />
<button id="buttonvalue" value="foo" tabindex="-1"></button>
12 changes: 3 additions & 9 deletions test/integration/rules/button-name/button-name.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
["#val"],
["#alempty"],
["#albmissing"],
["#albempty"]
["#albempty"],
["#buttonvalue"]
],
"passes": [
["#text"],
["#al"],
["#alb"],
["#combo"],
["#buttonTitle"],
["#inputTitle"]
]
"passes": [["#text"], ["#al"], ["#alb"], ["#combo"], ["#buttonTitle"]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@
<input type="reset" id="pass7" />
<input type="reset" value="" id="fail6" />
<input type="reset" value="Something" id="pass8" />
<input type="button" title="Something" id="pass9" />
<input type="submit" title="Something" id="pass10" />
<input type="reset" title="Something" id="pass11" />
</form>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "input-button-name test",
"rule": "button-name",
"rule": "input-button-name",
"violations": [
["#fail1"],
["#fail2"],
Expand All @@ -17,6 +17,9 @@
["#pass5"],
["#pass6"],
["#pass7"],
["#pass8"]
["#pass8"],
["#pass9"],
["#pass10"],
["#pass11"]
]
}

0 comments on commit ce20fbf

Please sign in to comment.