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:
+1
-1
@@ -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.
|
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
|
### 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.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+20
-1
@@ -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",
|
"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") {
|
if has_attr(attrs, "data-slhx-sse") && !has_attr(attrs, "data-slhx-root") {
|
||||||
return Err(invalid_slhx_placement(
|
return Err(invalid_slhx_placement(
|
||||||
path,
|
path,
|
||||||
@@ -1644,7 +1651,7 @@ fn main() {{
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rejects_invalid_slhx_attr_placement() {
|
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 [
|
for (case, template, attr, guidance) in [
|
||||||
(
|
(
|
||||||
"nav-button",
|
"nav-button",
|
||||||
@@ -1658,6 +1665,18 @@ fn main() {{
|
|||||||
"data-slhx-nav",
|
"data-slhx-nav",
|
||||||
"<a href=...>",
|
"<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",
|
"sse-child",
|
||||||
r#"<section data-slhx-root="feed"><div data-slhx-sse="/events"></div></section>"#,
|
r#"<section data-slhx-root="feed"><div data-slhx-sse="/events"></div></section>"#,
|
||||||
|
|||||||
Reference in New Issue
Block a user