Skip to content

Commit dbf503b

Browse files
authored
Merge pull request #3305 from Conduitry/gh-3226
use `change` event for `bind:files`
2 parents 620d26c + 2328d5e commit dbf503b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/compiler/compile/render_dom/wrappers/Element/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const events = [
2626
event_names: ['input'],
2727
filter: (node: Element, _name: string) =>
2828
node.name === 'textarea' ||
29-
node.name === 'input' && !/radio|checkbox|range/.test(node.get_static_attribute_value('type') as string)
29+
node.name === 'input' && !/radio|checkbox|range|file/.test(node.get_static_attribute_value('type') as string)
3030
},
3131
{
3232
event_names: ['input'],
@@ -38,7 +38,7 @@ const events = [
3838
event_names: ['change'],
3939
filter: (node: Element, _name: string) =>
4040
node.name === 'select' ||
41-
node.name === 'input' && /radio|checkbox/.test(node.get_static_attribute_value('type') as string)
41+
node.name === 'input' && /radio|checkbox|file/.test(node.get_static_attribute_value('type') as string)
4242
},
4343
{
4444
event_names: ['change', 'input'],

test/js/samples/input-files/expected.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function create_fragment(ctx) {
1919
input = element("input");
2020
attr(input, "type", "file");
2121
input.multiple = true;
22-
dispose = listen(input, "input", ctx.input_input_handler);
22+
dispose = listen(input, "change", ctx.input_change_handler);
2323
},
2424

2525
m(target, anchor) {
@@ -43,7 +43,7 @@ function create_fragment(ctx) {
4343
function instance($$self, $$props, $$invalidate) {
4444
let { files } = $$props;
4545

46-
function input_input_handler() {
46+
function input_change_handler() {
4747
files = this.files;
4848
$$invalidate('files', files);
4949
}
@@ -52,7 +52,7 @@ function instance($$self, $$props, $$invalidate) {
5252
if ('files' in $$props) $$invalidate('files', files = $$props.files);
5353
};
5454

55-
return { files, input_input_handler };
55+
return { files, input_change_handler };
5656
}
5757

5858
class Component extends SvelteComponent {

0 commit comments

Comments
 (0)