Skip to content

Commit c9202a8

Browse files
authored
feat: sort possible bindings in invalid binding error (#11950)
1 parent a412235 commit c9202a8

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

.changeset/witty-bikes-shave.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
feat: sort possible bindings in invalid binding error

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ const validation = {
421421
!binding_property.invalid_elements?.includes(parent.name))
422422
);
423423
})
424-
.map(([property_name]) => property_name);
424+
.map(([property_name]) => property_name)
425+
.sort();
425426
e.bind_invalid_name(
426427
node,
427428
node.name,

packages/svelte/tests/validator/samples/document-binding-invalid-dimensions/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "bind_invalid_name",
4-
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:document> are focused, activeElement, fullscreenElement, pointerLockElement, visibilityState, this",
4+
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:document> are activeElement, focused, fullscreenElement, pointerLockElement, this, visibilityState",
55
"start": {
66
"line": 5,
77
"column": 17

packages/svelte/tests/validator/samples/window-binding-invalid-dimensions/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "bind_invalid_name",
4-
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:window> are focused, innerWidth, innerHeight, outerWidth, outerHeight, scrollX, scrollY, online, devicePixelRatio, this",
4+
"message": "`bind:clientWidth` is not a valid binding. Possible bindings for <svelte:window> are devicePixelRatio, focused, innerHeight, innerWidth, online, outerHeight, outerWidth, scrollX, scrollY, this",
55
"start": {
66
"line": 5,
77
"column": 15

0 commit comments

Comments
 (0)