fix(build): reject empty slhx navigation hrefs

Treat data-slhx-nav anchors with empty static href values as build errors, preserving progressive navigation instead of letting links depend on JavaScript-only behavior.

req: page_swap/001

req: diagnostics/002
This commit is contained in:
slhx agent
2026-06-01 21:30:29 +02:00
parent 9b3fefbf50
commit ad135d81fe
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ slhx competes with React by making frontend frameworks unnecessary for most apps
## page_swap
### req: page_swap/001
001 Minimal page swapping is a first-class slhx-axum happy path. Authors mark real anchors with `data-slhx-nav`; links keep valid `href` and work without JS. Missing `href` on a static `data-slhx-nav` anchor is a build error.
001 Minimal page swapping is a first-class slhx-axum happy path. Authors mark real anchors with `data-slhx-nav`; links keep valid `href` and work without JS. Missing or empty static `href` on a `data-slhx-nav` anchor is a build error.
### req: page_swap/002
002 A `data-slhx-nav` click fetches the target URL as a slhx partial request. The response updates the canonical content slot, optionally navigation and title, then applies a `Navigate` effect.
+9 -1
View File
@@ -1067,7 +1067,9 @@ fn reject_invalid_slhx_attr_values(path: &Path, attrs: &[SurfaceAttribute]) -> i
}
fn reject_invalid_slhx_attr_placement(path: &Path, tag: &str, attrs: &[SurfaceAttribute]) -> io::Result<()> {
if has_attr(attrs, "data-slhx-nav") && (tag != "a" || !has_attr(attrs, "href")) {
if has_attr(attrs, "data-slhx-nav")
&& (tag != "a" || !has_attr(attrs, "href") || static_attr(attrs, "href").is_some_and(|href| href.trim().is_empty()))
{
return Err(invalid_slhx_placement(
path,
"data-slhx-nav",
@@ -1665,6 +1667,12 @@ fn main() {{
"data-slhx-nav",
"<a href=...>",
),
(
"nav-empty-href",
r#"<a href="" data-slhx-nav="">Docs</a>"#,
"data-slhx-nav",
"<a href=...>",
),
(
"boost-anchor",
r#"<a href="/docs" data-slhx-boost="">Docs</a>"#,