fix(build): reject boost on action elements

Treat data-slhx-boost on anchors and forms as a build error with guidance toward data-slhx-nav or data-slhx-handle, preserving boost as a container convention.

req: page_swap/007

req: diagnostics/002
This commit is contained in:
slhx agent
2026-06-01 21:24:55 +02:00
parent b6aaccf113
commit 9b3fefbf50
2 changed files with 21 additions and 2 deletions
+20 -1
View File
@@ -1074,6 +1074,13 @@ fn reject_invalid_slhx_attr_placement(path: &Path, tag: &str, attrs: &[SurfaceAt
"expected a real `<a href=...>` link so navigation works without JavaScript",
));
}
if has_attr(attrs, "data-slhx-boost") && matches!(tag, "a" | "form") {
return Err(invalid_slhx_placement(
path,
"data-slhx-boost",
"expected a container around descendant links/forms; use `data-slhx-nav` on anchors or `data-slhx-handle` on forms",
));
}
if has_attr(attrs, "data-slhx-sse") && !has_attr(attrs, "data-slhx-root") {
return Err(invalid_slhx_placement(
path,
@@ -1644,7 +1651,7 @@ fn main() {{
#[test]
fn rejects_invalid_slhx_attr_placement() {
// req: page_swap/001 req: push/006 req: diagnostics/002
// req: page_swap/001 req: page_swap/007 req: push/006 req: diagnostics/002
for (case, template, attr, guidance) in [
(
"nav-button",
@@ -1658,6 +1665,18 @@ fn main() {{
"data-slhx-nav",
"<a href=...>",
),
(
"boost-anchor",
r#"<a href="/docs" data-slhx-boost="">Docs</a>"#,
"data-slhx-boost",
"data-slhx-nav",
),
(
"boost-form",
r#"<form data-slhx-boost=""><input name="q"></form>"#,
"data-slhx-boost",
"data-slhx-handle",
),
(
"sse-child",
r#"<section data-slhx-root="feed"><div data-slhx-sse="/events"></div></section>"#,