Skip to content

Commit

Permalink
fix: add missing files binding (#9415)
Browse files Browse the repository at this point in the history
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 <rich.harris@vercel.com>
  • Loading branch information
dummdidumm and Rich-Harris committed Nov 13, 2023
1 parent 9aa06bd commit 7ab03ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-eggs-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: add missing files binding
4 changes: 4 additions & 0 deletions packages/svelte/src/compiler/phases/2-analyze/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ export const validation = {
if (node.name === 'checked' && type?.value[0].data !== 'checkbox') {
error(node, 'invalid-binding', node.name, '<input type="checkbox">');
}

if (node.name === 'files' && type?.value[0].data !== 'file') {
error(node, 'invalid-binding', node.name, '<input type="file">');
}
}

if (parent.name === 'select') {
Expand Down
5 changes: 5 additions & 0 deletions packages/svelte/src/compiler/phases/bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,10 @@ export const binding_properties = {
},
value: {
valid_elements: ['input', 'textarea', 'select']
},
files: {
event: 'change',
valid_elements: ['input'],
omit_in_ssr: true
}
};

1 comment on commit 7ab03ae

@vercel
Copy link

@vercel vercel bot commented on 7ab03ae Nov 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app

Please sign in to comment.