mirror of https://github.com/sveltejs/svelte
allow setting files (#9463)
parent
755fe33a57
commit
37f249350c
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: allow setting files binding for `<input type="file" />`
|
@ -0,0 +1,12 @@
|
||||
import { test } from '../../assert';
|
||||
|
||||
export default test({
|
||||
async test({ assert, window }) {
|
||||
const input = window.document.querySelector('input');
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
assert.equal(input?.files?.length, 1);
|
||||
window.document.querySelector('button')?.click();
|
||||
await new Promise((r) => setTimeout(r, 100));
|
||||
assert.equal(input?.files?.length, 0);
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
let files;
|
||||
|
||||
onMount(() => {
|
||||
let list = new DataTransfer();
|
||||
let file = new File(["content"], "filename.jpg");
|
||||
list.items.add(file);
|
||||
files = list.files;
|
||||
})
|
||||
</script>
|
||||
|
||||
<input type="file" bind:files />
|
||||
|
||||
<button onclick={() => files = new DataTransfer().files}>Reset</button>
|
Loading…
Reference in new issue