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

feat: separate form-field-multiple-label from label rule #1226

Merged
merged 7 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
| image-redundant-alt | Ensure button and link text is not repeated as image alternative | Minor | cat.text-alternatives, best-practice | true |
| input-image-alt | Ensures <input type="image"> elements have alternate text | Critical | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | 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 |
| label | Ensures every form element has a label | Minor, Serious, Critical | cat.forms, wcag2a, wcag332, wcag131, section508, section508.22.n | true |
| label | Ensures every form element has a label | Minor, Critical | cat.forms, wcag2a, wcag332, wcag131, section508, section508.22.n | true |
| landmark-banner-is-top-level | Ensures the banner landmark is at top level | Moderate | cat.semantics, best-practice | true |
| landmark-contentinfo-is-top-level | Ensures the contentinfo landmark is at top level | Moderate | cat.semantics, best-practice | true |
| landmark-main-is-top-level | Ensures the main landmark is at top level | Moderate | cat.semantics, best-practice | true |
Expand All @@ -56,6 +56,7 @@
| meta-refresh | Ensures <meta http-equiv="refresh"> is not used | Critical | cat.time, wcag2a, wcag2aaa, wcag221, wcag224, wcag325 | true |
| meta-viewport-large | Ensures <meta name="viewport"> can scale a significant amount | Minor | cat.sensory-and-visual-cues, best-practice | true |
| meta-viewport | Ensures <meta name="viewport"> does not disable text scaling and zooming | Critical | cat.sensory-and-visual-cues, wcag2aa, wcag144 | true |
| multiple-label | Ensures form element does not have multiple label elements | Serious | best-practice, cat.forms, wcag2a, wcag332 | true |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should change the impact to "moderate" for this. Best practices should not have an impact that is serious or critical. People don't like it when we do that :-)

| object-alt | Ensures <object> elements have alternate text | Serious | cat.text-alternatives, wcag2a, wcag111, section508, section508.22.a | true |
| p-as-heading | Ensure p elements are not used to style headings | Serious | cat.semantics, wcag2a, wcag131, experimental | true |
| page-has-heading-one | Ensure that the page, or at least one of its frames contains a level-one heading | Moderate | cat.semantics, best-practice | true |
Expand Down
1 change: 0 additions & 1 deletion lib/rules/label.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
],
"none": [
"help-same-as-label",
"multiple-label",
"hidden-explicit-label"
]
}
20 changes: 20 additions & 0 deletions lib/rules/multiple-label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"id": "multiple-label",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to name this something like "form-field-multiple-labels"?

"selector": "input, select, textarea",
"matches": "label-matches.js",
"tags": [
"best-practice",
"cat.forms",
"wcag2a",
"wcag332"
],
"metadata": {
"description": "Ensures form element does not have multiple label elements",
"help": "Form element must not have multiple associated label elements"
},
"all": [],
"any": [],
"none": [
"multiple-label"
]
}
3 changes: 1 addition & 2 deletions test/integration/rules/label/label.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
<textarea id="pass15" title="Label"></textarea>

<label><label><input type="text" id="fail22"></label></label>
<label for="fail23">Hi</label><label for="fail23">Foo</label><input type="text" id="fail23">

<div>
<label>
Expand Down Expand Up @@ -68,4 +67,4 @@
</div>

</div>
</form>
</form>
1 change: 0 additions & 1 deletion test/integration/rules/label/label.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
["#fail10"],
["#fail11"],
["#fail22"],
["#fail23"],
["#fail24"],
["#fail25"],
["#fail26"]
Expand Down
16 changes: 16 additions & 0 deletions test/integration/rules/multiple-label/multiple-label.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Fail -->
<label for="fail1">Hi</label>
<label for="fail1">Foo</label>
<input type="text" id="fail1">

<label for="fail2">label one</label>
<label for="fail2">label two</label>
<input type="checkbox" id="fail2">

<label for="fail3" id="l1">label one</label>
<label for="fail3">label two</label>
<input type="checkbox" id="fail3" aria-labelledby="l1">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add tests for:

  • implicit + explicit label
  • multiple implicit labels
  • select elements


<!-- Pass -->
<label for="pass1">Label</label><input type="text" id="pass1">
<textarea id="pass2" title="Label"></textarea>
13 changes: 13 additions & 0 deletions test/integration/rules/multiple-label/multiple-label.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"description": "multiple label test",
"rule": "multiple-label",
"violations": [
["#fail1"],
["#fail2"],
["#fail3"]
],
"passes": [
["#pass1"],
["#pass2"]
]
}