diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index a629e56..716f0ee 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -139,7 +139,7 @@ slhx competes with React by making frontend frameworks unnecessary for most apps 006 If a page lacks the expected `content` slot, slhx-axum falls back to normal browser navigation in production and emits a diagnostic in development. ### req: page_swap/007 -007 `data-slhx-boost` progressively enhances descendant same-origin anchors and forms. Links behave like `data-slhx-nav`; forms behave like slhx form submissions. External links, downloads, new-tab links, and modified-clicks preserve native browser behavior. +007 `data-slhx-boost` progressively enhances descendant same-origin anchors and forms. It is a container convention, not a replacement for `data-slhx-nav` on an anchor or `data-slhx-handle` on a form; placing it directly on static anchors or forms is a build error. Links behave like `data-slhx-nav`; forms behave like slhx form submissions. External links, downloads, new-tab links, and modified-clicks preserve native browser behavior. --- diff --git a/slhx-build/src/lib.rs b/slhx-build/src/lib.rs index 4001383..f1200d6 100644 --- a/slhx-build/src/lib.rs +++ b/slhx-build/src/lib.rs @@ -1074,6 +1074,13 @@ fn reject_invalid_slhx_attr_placement(path: &Path, tag: &str, attrs: &[SurfaceAt "expected a real `` 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", "", ), + ( + "boost-anchor", + r#"Docs"#, + "data-slhx-boost", + "data-slhx-nav", + ), + ( + "boost-form", + r#"
"#, + "data-slhx-boost", + "data-slhx-handle", + ), ( "sse-child", r#"
"#,