Skip to content
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