diff --git a/.changeset/great-icons-retire.md b/.changeset/great-icons-retire.md new file mode 100644 index 0000000000..53b789db25 --- /dev/null +++ b/.changeset/great-icons-retire.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: allow `bind:this` with dynamic type on inputs diff --git a/packages/svelte/src/compiler/phases/2-analyze/validation.js b/packages/svelte/src/compiler/phases/2-analyze/validation.js index 0b97284110..99cc8137d6 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/validation.js +++ b/packages/svelte/src/compiler/phases/2-analyze/validation.js @@ -323,7 +323,7 @@ export const validation = { ); } - if (parent.name === 'input') { + if (parent.name === 'input' && node.name !== 'this') { const type = /** @type {import('#compiler').Attribute | undefined} */ ( parent.attributes.find((a) => a.type === 'Attribute' && a.name === 'type') ); diff --git a/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/errors.json b/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/errors.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/errors.json @@ -0,0 +1 @@ +[] diff --git a/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/input.svelte b/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/input.svelte new file mode 100644 index 0000000000..70e0494c15 --- /dev/null +++ b/packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/input.svelte @@ -0,0 +1,6 @@ + + + \ No newline at end of file