Skip to content

Commit 85a3215

Browse files
committed
fix: allow bind:this with dynamic type on inputs
fixes #9709
1 parent bde42d5 commit 85a3215

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

.changeset/great-icons-retire.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+
fix: allow `bind:this` with dynamic type on inputs

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ export const validation = {
323323
);
324324
}
325325

326-
if (parent.name === 'input') {
326+
if (parent.name === 'input' && node.name !== 'this') {
327327
const type = /** @type {import('#compiler').Attribute | undefined} */ (
328328
parent.attributes.find((a) => a.type === 'Attribute' && a.name === 'type')
329329
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
let foo;
3+
let inputType;
4+
</script>
5+
6+
<input bind:this={foo} type={inputType}>

0 commit comments

Comments
 (0)