Skip to content

Commit 573acf9

Browse files
committed
Merge branch 'master' into version-4
2 parents 56df761 + 64b8c8b commit 573acf9

File tree

6 files changed

+23
-10
lines changed

6 files changed

+23
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
* Fix transitions so that they don't require a `style-src 'unsafe-inline'` Content Security Policy (CSP) ([#6662](https://github.com/sveltejs/svelte/issues/6662)).
2626
* Explicitly disallow `var` declarations extending the reactive statement scope ([#6800](https://github.com/sveltejs/svelte/pull/6800))
2727

28+
## 3.59.1
29+
30+
* Handle dynamic values in `a11y-autocomplete-valid` ([#8567](https://github.com/sveltejs/svelte/pull/8567))
31+
2832
## 3.59.0
2933

3034
* Add `ResizeObserver` bindings `contentRect`/`contentBoxSize`/`borderBoxSize`/`devicePixelContentBoxSize` ([#8022](https://github.com/sveltejs/svelte/pull/8022))
@@ -37,6 +41,7 @@
3741
* Fix type of `VERSION` compiler export ([#8498](https://github.com/sveltejs/svelte/issues/8498))
3842
* Relax `a11y-no-redundant-roles` warning ([#8536](https://github.com/sveltejs/svelte/pull/8536))
3943
* Handle nested array rest destructuring ([#8552](https://github.com/sveltejs/svelte/issues/8552), [#8554](https://github.com/sveltejs/svelte/issues/8554))
44+
4045
## 3.58.0
4146

4247
* Add `bind:innerText` for `contenteditable` elements ([#3311](https://github.com/sveltejs/svelte/issues/3311))

src/compiler/compile/compiler_warnings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export default {
172172
}),
173173
a11y_autocomplete_valid: (type: null | true | string, value: null | true | string) => ({
174174
code: 'a11y-autocomplete-valid',
175-
message: `A11y: The value '${value}' is not supported by the attribute 'autocomplete' on element <input type="${type}">`
175+
message: `A11y: The value '${value}' is not supported by the attribute 'autocomplete' on element <input type="${type || '...'}">`
176176
}),
177177
a11y_img_redundant_alt: {
178178
code: 'a11y-img-redundant-alt',

src/compiler/compile/nodes/Element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ export default class Element extends Node {
927927
const type_value = type.get_static_value();
928928
const autocomplete_value = autocomplete.get_static_value();
929929

930-
if (!is_valid_autocomplete(type_value, autocomplete_value)) {
930+
if (!is_valid_autocomplete(autocomplete_value)) {
931931
component.warn(autocomplete, compiler_warnings.a11y_autocomplete_valid(type_value, autocomplete_value));
932932
}
933933
}

src/compiler/compile/utils/a11y.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,11 @@ const autofill_contact_field_name_tokens = new Set([
295295
'impp'
296296
]);
297297

298-
export function is_valid_autocomplete(type: null | true | string, autocomplete: null | true | string) {
299-
if (typeof autocomplete !== 'string' || typeof type !== 'string') {
298+
export function is_valid_autocomplete(autocomplete: null | true | string) {
299+
if (autocomplete === true) {
300300
return false;
301+
} else if (!autocomplete) {
302+
return true; // dynamic value
301303
}
302304

303305
const tokens = autocomplete.trim().toLowerCase().split(regex_whitespaces);

test/validator/samples/a11y-autocomplete-valid/input.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
<script>
2+
let dynamic = '';
3+
</script>
4+
15
<!-- VALID -->
26
<input type="text" />
37
<input type="text" autocomplete="name" />
@@ -14,6 +18,8 @@
1418
<input type="hidden" autocomplete="off" />
1519
<input type="hidden" autocomplete="on" />
1620
<input type="text" autocomplete="" />
21+
<input type="{dynamic}" autocomplete="" />
22+
<input type="text" autocomplete="{dynamic}" />
1723

1824
<!-- INVALID -->
1925
<input type="text" autocomplete />

test/validator/samples/a11y-autocomplete-valid/warnings.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
"code": "a11y-autocomplete-valid",
44
"end": {
55
"column": 31,
6-
"line": 19
6+
"line": 25
77
},
88
"message": "A11y: The value 'true' is not supported by the attribute 'autocomplete' on element <input type=\"text\">",
99
"start": {
1010
"column": 19,
11-
"line": 19
11+
"line": 25
1212
}
1313
},
1414
{
1515
"code": "a11y-autocomplete-valid",
1616
"end": {
1717
"column": 43,
18-
"line": 20
18+
"line": 26
1919
},
2020
"message": "A11y: The value 'incorrect' is not supported by the attribute 'autocomplete' on element <input type=\"text\">",
2121
"start": {
2222
"column": 19,
23-
"line": 20
23+
"line": 26
2424
}
2525
},
2626
{
2727
"code": "a11y-autocomplete-valid",
2828
"end": {
2929
"column": 42,
30-
"line": 21
30+
"line": 27
3131
},
3232
"message": "A11y: The value 'webauthn' is not supported by the attribute 'autocomplete' on element <input type=\"text\">",
3333
"start": {
3434
"column": 19,
35-
"line": 21
35+
"line": 27
3636
}
3737
}
3838
]

0 commit comments

Comments
 (0)