From 7ab03ae36c5b9f46972285033b304ba653ea93ed Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:14:23 +0100 Subject: [PATCH] fix: add missing files binding (#9415) no two-way binding because setting it involves a `DataTransfer` workaround, so it's not really officially supported that way - if you need that, you shouldn't use that binding probably. This matches the behavior in Svelte 4. Co-authored-by: Rich Harris --- .changeset/poor-eggs-enjoy.md | 5 +++++ packages/svelte/src/compiler/phases/2-analyze/validation.js | 4 ++++ packages/svelte/src/compiler/phases/bindings.js | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 .changeset/poor-eggs-enjoy.md diff --git a/.changeset/poor-eggs-enjoy.md b/.changeset/poor-eggs-enjoy.md new file mode 100644 index 0000000000..2ca830a1de --- /dev/null +++ b/.changeset/poor-eggs-enjoy.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: add missing files binding diff --git a/packages/svelte/src/compiler/phases/2-analyze/validation.js b/packages/svelte/src/compiler/phases/2-analyze/validation.js index f04fe2fbf1..7d421cd07e 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/validation.js +++ b/packages/svelte/src/compiler/phases/2-analyze/validation.js @@ -325,6 +325,10 @@ export const validation = { if (node.name === 'checked' && type?.value[0].data !== 'checkbox') { error(node, 'invalid-binding', node.name, ''); } + + if (node.name === 'files' && type?.value[0].data !== 'file') { + error(node, 'invalid-binding', node.name, ''); + } } if (parent.name === 'select') { diff --git a/packages/svelte/src/compiler/phases/bindings.js b/packages/svelte/src/compiler/phases/bindings.js index 17a5ec3b61..2f891827cc 100644 --- a/packages/svelte/src/compiler/phases/bindings.js +++ b/packages/svelte/src/compiler/phases/bindings.js @@ -179,5 +179,10 @@ export const binding_properties = { }, value: { valid_elements: ['input', 'textarea', 'select'] + }, + files: { + event: 'change', + valid_elements: ['input'], + omit_in_ssr: true } };