From f88895e95582db3ebfba2308edb76bd5efab18f2 Mon Sep 17 00:00:00 2001
From: Simon H <5968653+dummdidumm@users.noreply.github.com>
Date: Thu, 30 Nov 2023 09:29:31 +0100
Subject: [PATCH] fix: allow `bind:this` with dynamic type on inputs (#9713)
fixes #9709
---
.changeset/great-icons-retire.md | 5 +++++
packages/svelte/src/compiler/phases/2-analyze/validation.js | 2 +-
.../samples/binding-this-input-type-dynamic/errors.json | 1 +
.../samples/binding-this-input-type-dynamic/input.svelte | 6 ++++++
4 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 .changeset/great-icons-retire.md
create mode 100644 packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/errors.json
create mode 100644 packages/svelte/tests/validator/samples/binding-this-input-type-dynamic/input.svelte
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