fix playwright tests by fixing inlinejs

This commit is contained in:
Jonathan Kelley 2024-01-08 13:58:47 -08:00
parent 6b240e1169
commit 8ef7503a90
No known key found for this signature in database
GPG key ID: 1FBB50F7EB0A08BE
2 changed files with 17 additions and 16 deletions

View file

@ -43,6 +43,7 @@ features = [
"Text", "Text",
"Window", "Window",
"DataTransfer", "DataTransfer",
"console"
] ]
[features] [features]
@ -50,7 +51,6 @@ default = ["panic_hook", "mounted", "file_engine", "hot_reload", "eval"]
panic_hook = ["console_error_panic_hook"] panic_hook = ["console_error_panic_hook"]
hydrate = [ hydrate = [
"web-sys/Comment", "web-sys/Comment",
"web-sys/console",
] ]
mounted = [ mounted = [
"web-sys/Element", "web-sys/Element",

View file

@ -525,26 +525,27 @@ impl HasFileData for WebDragData {
// web-sys does not expose the keys api for form data, so we need to manually bind to it // web-sys does not expose the keys api for form data, so we need to manually bind to it
#[wasm_bindgen(inline_js = r#" #[wasm_bindgen(inline_js = r#"
export function get_form_data(form) { export function get_form_data(form) {
let values = new Map(); let values = new Map();
const formData = new FormData(form); const formData = new FormData(form);
for (let name of formData.keys()) { for (let name of formData.keys()) {
const fieldType = target.elements[name].type; const fieldType = target.elements[name].type;
switch (fieldType) { switch (fieldType) {
case "select-multiple": case "select-multiple":
contents.values[name] = formData.getAll(name); contents.values[name] = formData.getAll(name);
break; break;
// add cases for fieldTypes that can hold multiple values here // add cases for fieldTypes that can hold multiple values here
default: default:
contents.values[name] = formData.get(name); contents.values[name] = formData.get(name);
break; break;
} }
return values;
} }
return values;
}
"#)] "#)]
extern "C" { extern "C" {
fn get_form_data(form: &web_sys::HtmlFormElement) -> js_sys::Map; fn get_form_data(form: &web_sys::HtmlFormElement) -> js_sys::Map;