Skip to content

Commit 4182917

Browse files
committed
Bug fix autocomplete
1 parent 22740b4 commit 4182917

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

lib/checks/forms/autocomplete-valid.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"id": "autocomplete-valid",
33
"evaluate": "autocomplete-a11y-evaluate",
44
"metadata": {
5-
"impact": "serious",
5+
"impact": "moderate",
66
"messages": {
77
"pass": "the autocomplete attribute is correctly formatted",
8-
"fail": "the autocomplete attribute is incorrectly formatted"
8+
"fail": "Add autocomplete attribute to form fields with a valid value as per HTML specification. In 'name' attribute of field, prefer to use standard autocomplete value since browsers use 'name' to suggest autofill. For field with no standard autocomplete value (eg: College ID), prefer to use autocomplete='on'."
99
}
1010
},
1111
"options": {

lib/rules/autocomplete-matches.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { sanitize } from '../commons/text';
22
import standards from '../standards';
33
import { isVisible } from '../commons/dom';
44

5-
function autocompleteMatches(node, virtualNode, flag=false) {
5+
function autocompleteMatches(node, virtualNode, flag = false) {
66
const autocomplete = virtualNode.attr('autocomplete');
77
if ((!autocomplete || sanitize(autocomplete) === '') && !flag) {
88
return false;
@@ -13,8 +13,17 @@ function autocompleteMatches(node, virtualNode, flag=false) {
1313
return false;
1414
}
1515

16-
// The element is an `input` element a `type` of `hidden`, `button`, `submit` or `reset`
17-
const excludedInputTypes = ['submit', 'reset', 'button', 'hidden'];
16+
// The element is an `input` element a `type` of `hidden`, `reset`,`button`, `submit` , 'checkbox', 'file', 'image', or 'radio'
17+
const excludedInputTypes = [
18+
'submit',
19+
'reset',
20+
'button',
21+
'hidden',
22+
'checkbox',
23+
'file',
24+
'image',
25+
'radio'
26+
];
1827
if (
1928
nodeName === 'input' &&
2029
excludedInputTypes.includes(virtualNode.props.type)

lib/rules/autocomplete-valid.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
{
22
"id": "autocomplete-valid",
33
"matches": "autocomplete-a11y-matches",
4-
"tags": ["cat.forms", "wcag21aa", "wcag135"],
4+
"tags": [
5+
"cat.forms",
6+
"wcag21aa",
7+
"wcag22aa",
8+
"wcag135",
9+
"a11y-engine",
10+
"a11y-engine-experimental"
11+
],
512
"actIds": ["73f2c2"],
613
"metadata": {
7-
"description": "Ensure the autocomplete attribute is correct and suitable for the form field",
8-
"help": "autocomplete attribute must be used correctly"
14+
"description": "Ensure that the necessary form fields use the autocomplete attribute with a valid input.",
15+
"help": "Autocomplete attribute must have a valid value"
916
},
1017
"all": ["autocomplete-valid"],
1118
"any": [],

0 commit comments

Comments
 (0)