diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts
index 3aee4b14c2..81e61ef86b 100644
--- a/src/compiler/compile/nodes/Element.ts
+++ b/src/compiler/compile/nodes/Element.ts
@@ -853,8 +853,8 @@ export default class Element extends Node {
const autocomplete = attribute_map.get('autocomplete');
if (type && autocomplete) {
- const type_value: null | true | string = type.get_static_value();
- const autocomplete_value: null | true | string = autocomplete.get_static_value();
+ const type_value = type.get_static_value();
+ const autocomplete_value = autocomplete.get_static_value();
if (!is_valid_autocomplete(type_value, autocomplete_value)) {
component.warn(autocomplete, compiler_warnings.a11y_autocomplete_valid(type_value, autocomplete_value));
diff --git a/src/compiler/compile/utils/a11y.ts b/src/compiler/compile/utils/a11y.ts
index 7f9a529a27..0d24f5dbda 100644
--- a/src/compiler/compile/utils/a11y.ts
+++ b/src/compiler/compile/utils/a11y.ts
@@ -228,6 +228,9 @@ export function is_semantic_role_element(role: ARIARoleDefinitionKey, tag_name:
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute
const address_type_tokens = new Set(['shipping', 'billing']);
const autofill_field_name_tokens = new Set([
+ '',
+ 'on',
+ 'off',
'name',
'honorific-prefix',
'given-name',
@@ -293,16 +296,6 @@ export function is_valid_autocomplete(type: null | true | string, autocomplete:
}
const tokens = autocomplete.trim().toLowerCase().split(regex_whitespaces);
- const normalized_type = type.toLowerCase();
-
- const input_wears_autofill_anchor_mantle = normalized_type === 'hidden';
- const input_wears_autofill_expectation_mantle = !input_wears_autofill_anchor_mantle;
-
- if (input_wears_autofill_expectation_mantle) {
- if (tokens[0] === 'on' || tokens[0] === 'off') {
- return tokens.length === 1;
- }
- }
if (typeof tokens[0] === 'string' && tokens[0].startsWith('section-')) {
tokens.shift();
diff --git a/test/validator/samples/a11y-autocomplete-valid/input.svelte b/test/validator/samples/a11y-autocomplete-valid/input.svelte
index 28de32bb86..1f47878e37 100644
--- a/test/validator/samples/a11y-autocomplete-valid/input.svelte
+++ b/test/validator/samples/a11y-autocomplete-valid/input.svelte
@@ -11,11 +11,11 @@
-
-
-
+
+
+
diff --git a/test/validator/samples/a11y-autocomplete-valid/warnings.json b/test/validator/samples/a11y-autocomplete-valid/warnings.json
index c7e5ab9490..dfde14a51f 100644
--- a/test/validator/samples/a11y-autocomplete-valid/warnings.json
+++ b/test/validator/samples/a11y-autocomplete-valid/warnings.json
@@ -3,45 +3,9 @@
"code": "a11y-autocomplete-valid",
"end": {
"column": 31,
- "line": 16
- },
- "message": "A11y: The value 'true' is not supported by the attribute 'autocomplete' on element ",
- "start": {
- "column": 19,
- "line": 16
- }
- },
- {
- "code": "a11y-autocomplete-valid",
- "end": {
- "column": 39,
- "line": 17
- },
- "message": "A11y: The value 'off' is not supported by the attribute 'autocomplete' on element ",
- "start": {
- "column": 21,
- "line": 17
- }
- },
- {
- "code": "a11y-autocomplete-valid",
- "message": "A11y: The value 'on' is not supported by the attribute 'autocomplete' on element ",
- "end": {
- "column": 38,
- "line": 18
- },
- "start": {
- "column": 21,
- "line": 18
- }
- },
- {
- "code": "a11y-autocomplete-valid",
- "message": "A11y: The value '' is not supported by the attribute 'autocomplete' on element ",
- "end": {
- "column": 34,
"line": 19
},
+ "message": "A11y: The value 'true' is not supported by the attribute 'autocomplete' on element ",
"start": {
"column": 19,
"line": 19