From 8ef7503a908e01733ab506414e692a38b6e1e649 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Mon, 8 Jan 2024 13:58:47 -0800 Subject: [PATCH] fix playwright tests by fixing inlinejs --- packages/web/Cargo.toml | 2 +- packages/web/src/event.rs | 31 ++++++++++++++++--------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/web/Cargo.toml b/packages/web/Cargo.toml index 12c2c974a..2f507615e 100644 --- a/packages/web/Cargo.toml +++ b/packages/web/Cargo.toml @@ -43,6 +43,7 @@ features = [ "Text", "Window", "DataTransfer", + "console" ] [features] @@ -50,7 +51,6 @@ default = ["panic_hook", "mounted", "file_engine", "hot_reload", "eval"] panic_hook = ["console_error_panic_hook"] hydrate = [ "web-sys/Comment", - "web-sys/console", ] mounted = [ "web-sys/Element", diff --git a/packages/web/src/event.rs b/packages/web/src/event.rs index ae21414db..9e5ca9421 100644 --- a/packages/web/src/event.rs +++ b/packages/web/src/event.rs @@ -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 #[wasm_bindgen(inline_js = r#" - export function get_form_data(form) { - let values = new Map(); - const formData = new FormData(form); +export function get_form_data(form) { + let values = new Map(); + const formData = new FormData(form); - for (let name of formData.keys()) { - const fieldType = target.elements[name].type; + for (let name of formData.keys()) { + const fieldType = target.elements[name].type; - switch (fieldType) { - case "select-multiple": - contents.values[name] = formData.getAll(name); - break; + switch (fieldType) { + case "select-multiple": + contents.values[name] = formData.getAll(name); + break; - // add cases for fieldTypes that can hold multiple values here - default: - contents.values[name] = formData.get(name); - break; + // add cases for fieldTypes that can hold multiple values here + default: + contents.values[name] = formData.get(name); + break; } - - return values; } + + return values; +} "#)] extern "C" { fn get_form_data(form: &web_sys::HtmlFormElement) -> js_sys::Map;