Skip to content

Commit

Permalink
Checks added for attributes in label and input element (#43)
Browse files Browse the repository at this point in the history
Co-authored-by: Jack Domleo <[email protected]>
  • Loading branch information
Being-Maverick and jackdomleo7 authored Nov 12, 2020
1 parent 07c0bdd commit 693dbf3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
36 changes: 36 additions & 0 deletions checka11y.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,39 @@ u::after {
content: "WARNING: Using <u> -moz-element could be confused as a hyperlink, consider using a different -moz-element such as <em> or <b>." !important;
content: "WARNING: Using <u> element could be confused as a hyperlink, consider using a different element such as <em> or <b>." !important;
}

label:not([for]){
border: var(--checka11y-error-border-width, 5px) solid var(--checka11y-error-color, red) !important;
}

label:not([for])::after{
content: "ERROR: Ensure that <label> is always provided with a [for] attribute" !important;
font-family: var(--checka11y-font, cursive);
}

label[for=""]{
border: var(--checka11y-error-border-width, 5px) solid var(--checka11y-error-color, red) !important;
}

label[for=""]::after{
content: "ERROR: Ensure that [for] in a <label> is not empty" !important;
font-family: var(--checka11y-font, cursive);
}

input:not([name])::after{
border: var(--checka11y-error-border-width, 5px) solid var(--checka11y-error-color, red) !important;
}

input:not([name])::after{
content: "ERROR: Ensure that <input> is always provided with a [name] attribute" !important;
font-family: var(--checka11y-font, cursive);
}

input[name=""]::after{
border: var(--checka11y-error-border-width, 5px) solid var(--checka11y-error-color, red) !important;
}

input[name=""]::after{
content: "ERROR: Ensure that [name] in a <input> is not empty" !important;
font-family: var(--checka11y-font, cursive);
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"Manaswini Munuguri (https://github.com/Manaswini1832)",
"Shona McKenzie (https://github.com/shonamckenzie)",
"Ashar Setiawan (https://github.com/azhsetiawan)",
"Bogdan Lazar (https://github.com/tricinel)"
"Bogdan Lazar (https://github.com/tricinel)",
"Charchit Kapoor <[email protected]> (https://github.com/Being-Maverick)"
],
"keywords": [
"checka11y",
Expand Down
11 changes: 11 additions & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,16 @@ <h2>Avoide using mouse event handlers without the appropriate keyboard alternati
<div onclick="" onkeydown="" role="button" tabindex="-1">A div with onclick, onkeydown, role=button and tabindex=-1</div>
</div>
</section>
<section>
<label for="for">This is a label with a for attribute</label>
<hr/>
<label></label>
<hr/>
<label for=""></label>
</section>
<section>
<h2>Description: &lt;input&gt; should always be provided a non-empty name attribute</h2>
<input name="input-1" type="button" value="Button"/>
</section>
</body>
</html>

0 comments on commit 693dbf3

Please sign in to comment.