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

fix(autocomplete-valid): incomplete for invalid but safe values #4500

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
8 changes: 4 additions & 4 deletions doc/rule-descriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@

## WCAG 2.1 Level A & AA Rules

| Rule ID | Description | Impact | Tags | Issue Type | ACT Rules |
| :----------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- | :------ | :-------------------------------------------------------------- | :--------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [autocomplete-valid](https://dequeuniversity.com/rules/axe/4.9/autocomplete-valid?application=RuleDescription) | Ensure the autocomplete attribute is correct and suitable for the form field | Serious | cat.forms, wcag21aa, wcag135, EN-301-549, EN-9.1.3.5, ACT | failure | [73f2c2](https://act-rules.github.io/rules/73f2c2) |
| [avoid-inline-spacing](https://dequeuniversity.com/rules/axe/4.9/avoid-inline-spacing?application=RuleDescription) | Ensure that text spacing set through style attributes can be adjusted with custom stylesheets | Serious | cat.structure, wcag21aa, wcag1412, EN-301-549, EN-9.1.4.12, ACT | failure | [24afc2](https://act-rules.github.io/rules/24afc2), [9e45ec](https://act-rules.github.io/rules/9e45ec), [78fd32](https://act-rules.github.io/rules/78fd32) |
| Rule ID | Description | Impact | Tags | Issue Type | ACT Rules |
| :----------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------- | :------ | :-------------------------------------------------------------- | :------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [autocomplete-valid](https://dequeuniversity.com/rules/axe/4.9/autocomplete-valid?application=RuleDescription) | Ensure the autocomplete attribute is correct and suitable for the form field | Serious | cat.forms, wcag21aa, wcag135, EN-301-549, EN-9.1.3.5, ACT | failure, needs review | [73f2c2](https://act-rules.github.io/rules/73f2c2) |
| [avoid-inline-spacing](https://dequeuniversity.com/rules/axe/4.9/avoid-inline-spacing?application=RuleDescription) | Ensure that text spacing set through style attributes can be adjusted with custom stylesheets | Serious | cat.structure, wcag21aa, wcag1412, EN-301-549, EN-9.1.4.12, ACT | failure | [24afc2](https://act-rules.github.io/rules/24afc2), [9e45ec](https://act-rules.github.io/rules/9e45ec), [78fd32](https://act-rules.github.io/rules/78fd32) |

## WCAG 2.2 Level A & AA Rules

Expand Down
2 changes: 1 addition & 1 deletion lib/checks/forms/autocomplete-valid-evaluate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isValidAutocomplete } from '../../commons/text';

function autocompleteValidEvaluate(node, options, virtualNode) {
function autocompleteValidEvaluate(_node, options, virtualNode) {
const autocomplete = virtualNode.attr('autocomplete') || '';
return isValidAutocomplete(autocomplete, options);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/checks/forms/autocomplete-valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"impact": "serious",
"messages": {
"pass": "the autocomplete attribute is correctly formatted",
"fail": "the autocomplete attribute is incorrectly formatted"
"fail": "the autocomplete attribute is incorrectly formatted",
"incomplete": "check that this invalid autocomplete attribute does not necessary for accessibility"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"incomplete": "check that this invalid autocomplete attribute does not necessary for accessibility"
"incomplete": "check that this unknown autocomplete attribute does not necessary for accessibility"

}
},
"options": {
Expand Down
8 changes: 7 additions & 1 deletion lib/commons/text/is-valid-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export const autocomplete = {
'email',
'impp'
],
locations: ['billing', 'shipping']
locations: ['billing', 'shipping'],
ignoredValues: ['text', 'pronouns', 'gender', 'message', 'content']
};

function isValidAutocomplete(
Expand Down Expand Up @@ -117,6 +118,11 @@ function isValidAutocomplete(
}

const purposeTerm = autocompleteTerms[autocompleteTerms.length - 1];

if (autocomplete.ignoredValues.includes(purposeTerm)) {
return undefined;
}

return (
standaloneTerms.includes(purposeTerm) ||
qualifiedTerms.includes(purposeTerm)
Expand Down
3 changes: 2 additions & 1 deletion locales/_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,8 @@
},
"autocomplete-valid": {
"pass": "the autocomplete attribute is correctly formatted",
"fail": "the autocomplete attribute is incorrectly formatted"
"fail": "the autocomplete attribute is incorrectly formatted",
"incomplete": "check that this invalid autocomplete attribute does not necessary for accessibility"
},
"accesskeys": {
"pass": "Accesskey attribute value is unique",
Expand Down
5 changes: 5 additions & 0 deletions test/checks/forms/autocomplete-valid.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ describe('autocomplete-valid', function () {
assert.isFalse(evaluate.apply(checkContext, params));
});

it('returns undefined (incomplete) if autocomplete is ignored', function () {
var params = checkSetup('<input autocomplete="text" id="target" />');
assert.isUndefined(evaluate.apply(checkContext, params));
});

it('uses options to change what is valid autocomplete', function () {
var options = { stateTerms: ['foo'] };
var params = checkSetup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,10 @@
<input autocomplete="section-foo email webauthn" id="pass92" />
<input autocomplete="section-foo work email webauthn" id="pass93" />
<input autocomplete="section-foo billing work email webauthn" id="pass94" />

<!-- Incomplete, ignored values -->
<input autocomplete="text" id="incomplete1" />
<input autocomplete="pronouns" id="incomplete2" />
<input autocomplete="gender" id="incomplete3" />
<input autocomplete="message" id="incomplete4" />
<input autocomplete="content" id="incomplete5" />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"description": "autocomplete-valid tests",
"rule": "autocomplete-valid",
"violations": [["#fail1"], ["#fail2"], ["#fail3"], ["#fail4"], ["#fail5"]],
"incomplete": [
["#incomplete1"],
["#incomplete2"],
["#incomplete3"],
["#incomplete4"],
["#incomplete5"]
],
"passes": [
["#pass1"],
["#pass2"],
Expand Down
Loading