fix(runtime): make form defaults post declaratively
req: form/002 req: examples/005 req: convention/004
This commit is contained in:
@@ -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";
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user