Skip to content

Commit 7ab03ae

Browse files
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 <[email protected]>
1 parent 9aa06bd commit 7ab03ae

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.changeset/poor-eggs-enjoy.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: add missing files binding

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ export const validation = {
325325
if (node.name === 'checked' && type?.value[0].data !== 'checkbox') {
326326
error(node, 'invalid-binding', node.name, '<input type="checkbox">');
327327
}
328+
329+
if (node.name === 'files' && type?.value[0].data !== 'file') {
330+
error(node, 'invalid-binding', node.name, '<input type="file">');
331+
}
328332
}
329333

330334
if (parent.name === 'select') {

packages/svelte/src/compiler/phases/bindings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,10 @@ export const binding_properties = {
179179
},
180180
value: {
181181
valid_elements: ['input', 'textarea', 'select']
182+
},
183+
files: {
184+
event: 'change',
185+
valid_elements: ['input'],
186+
omit_in_ssr: true
182187
}
183188
};

0 commit comments

Comments
 (0)