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
+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"));