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: allow bind:this on <select> with dynamic multiple attribute #11378

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions .changeset/healthy-ants-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: allow `bind:this` on `<select>` with dynamic `multiple` attribute
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ const validation = {
}
}

if (parent.name === 'select') {
if (parent.name === 'select' && node.name !== 'this') {
const multiple = parent.attributes.find(
(a) =>
a.type === 'Attribute' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"code": "attribute_invalid_multiple",
"message": "'multiple' attribute must be static if select uses two-way binding",
"start": {
"line": 6,
"line": 14,
"column": 19
},
"end": {
"line": 6,
"line": 14,
"column": 29
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
let multiple;
</script>

<!-- ok -->
<select bind:this={value} {multiple}>
<option>1</option>
<option>2</option>
<option>3</option>
</select>

<!-- error -->
<select bind:value {multiple}>
<option>1</option>
<option>2</option>
Expand Down
Loading