pull/10617/head
Simon Holthausen 2 years ago
parent 10a908ee78
commit 286398bed7

@ -2841,6 +2841,10 @@ export const template_visitors = {
break;
}
case 'files':
call_expr = b.call(`$.bind_files`, state.node, getter, setter);
break;
case 'this':
call_expr = serialize_bind_this(node.expression, context, state.node);
break;

@ -182,8 +182,6 @@ export const binding_properties = {
valid_elements: ['input', 'textarea', 'select']
},
files: {
event: 'change',
type: 'set',
valid_elements: ['input'],
omit_in_ssr: true
}

@ -175,3 +175,17 @@ function is_numberlike_input(input) {
function to_number(value) {
return value === '' ? null : +value;
}
/**
* @param {HTMLInputElement} input
* @param {() => FileList | null} get_value
* @param {(value: FileList | null) => void} update
*/
export function bind_files(input, get_value, update) {
listen_to_event_and_reset_event(input, 'change', () => {
update(input.files);
});
render_effect(() => {
input.files = get_value();
});
}

Loading…
Cancel
Save