fix(runtime): make form defaults post declaratively

req: form/002

req: examples/005

req: convention/004
This commit is contained in:
slhx agent
2026-05-11 08:55:08 +02:00
parent 5c1dc853d8
commit 63b559edb8
4 changed files with 8 additions and 3 deletions
@@ -16,7 +16,7 @@
<section class="workspace">
<aside class="command-card">
<h2>Create an issue</h2>
<form id="launch-work" data-slhx-handle="launch_work" data-slhx-form="launch_work" data-slhx-disable-while-pending>
<form id="launch-work" method="post" data-slhx-handle="launch_work" data-slhx-form="launch_work" data-slhx-disable-while-pending>
<input type="hidden" name="__h" value="539242093">
<label>Title <input name="title" required="required" value="Ship typed effects"></label>
<label>Lane
@@ -27,7 +27,7 @@
</select>
</label>
<label>Impact <input name="impact" type="number" min="1" max="9" value="7"></label>
<button class="primary-action" type="button" data-slhx-handle="launch_work">Create issue</button>
<button class="primary-action" type="button" form="launch-work" data-slhx-handle="launch_work" data-slhx-on="click">Create issue</button>
</form>
<div class="quick-actions">
<button type="button" data-slhx-handle="simulate_push">Simulate server push</button>
+4
View File
@@ -59,6 +59,10 @@ async fn browser_drives_typed_product_end_to_end() -> WebDriverResult<()> {
.await?;
wait_for_text(&driver, &slot_selector(ui::control_center::slots::notice.id().id), "Push simulated").await?;
driver.find(By::Css("button.primary-action")).await?.click().await?;
wait_for_text(&driver, ".work-card[data-key='4']", "Ship typed effects").await?;
assert_text(&driver, "width:77%").await?;
drag_card_to_lane(&driver, 2, "product").await?;
wait_for_text(&driver, ".lane[data-lane='product'] .work-card[data-key='2']", "Shipped").await?;
wait_for_text(&driver, &slot_selector(ui::control_center::slots::notice.id().id), "Drag-and-drop move persisted").await?;
+1 -1
View File
@@ -123,7 +123,7 @@
const abort = new AbortController();
let finish;
const done = new Promise((resolve) => { finish = resolve; });
const method = String((form && form.method) || "POST").toUpperCase();
const method = String((form && form.getAttribute("method")) || "POST").toUpperCase();
const body = method === "GET" || method === "HEAD" ? undefined : requestBody(data, multipart);
const headers = { "X-SLHX-Partial": "1", "Accept": "application/slhx, text/html" };
if (body instanceof URLSearchParams) headers["Content-Type"] = "application/x-www-form-urlencoded;charset=UTF-8";
+1
View File
@@ -3,6 +3,7 @@ fn runtime_posts_urlencoded_forms_by_default() {
let source = slhx_js::RUNTIME_JS;
assert!(source.contains("new URLSearchParams()"));
assert!(source.contains("form.getAttribute(\"method\")"));
assert!(source.contains("multipart/form-data"));
assert!(source.contains("const body = method === \"GET\" || method === \"HEAD\" ? undefined : requestBody(data, multipart)"));
assert!(source.contains("application/x-www-form-urlencoded;charset=UTF-8"));