fix(build): lower rendered loop keys
req: list/002
This commit is contained in:
@@ -35,6 +35,7 @@ Keep it stable. Prefer pointers to canonical sources over copied structure, file
|
||||
- First split intent into broad error classes: what can go wrong, and what outcome must hold.
|
||||
- Test the largest risky classes before narrow examples.
|
||||
- Add adversarial tests for malformed, hostile, ambiguous, missing, duplicated, and boundary inputs.
|
||||
- When changing generated lowering, prove dynamic rendered attributes at the consumer boundary; literal lowering fixtures alone are insufficient.
|
||||
- Do not over-codify existing behavior while direction is still moving.
|
||||
- Add narrow concrete tests only after requirements converge into a stable direction.
|
||||
|
||||
|
||||
+1
-1
@@ -320,7 +320,7 @@ resources. Concrete runtime targets are addressed through `ResourceRef`
|
||||
|
||||
004 Without a key, hemx-addressable nodes inside a loop are rejected at build time. Keyed identity is `ResourceRef { resource: ResourceId, scope: Some(ScopeKey::KeyValue(...)) }`. [north_star]
|
||||
|
||||
002 Slots inside a keyed loop receive a composite identity. hemplate records `key_expr` in the Surface; hemx implements keyed slot lookups. [north_star]
|
||||
002 Slots inside a keyed loop receive a composite identity. hemplate records `key_expr` in the Surface; hemx implements keyed slot lookups and lowers rendered `h-key` identity to its private `data-key` runtime marker. [north_star]
|
||||
|
||||
003 Generated helpers for keyed slots are `append(view)`, `prepend(view)`, `replace(view)`, and `remove(key_or_view)` when the template and view type provide an unambiguous `h-key`. [north_star]
|
||||
|
||||
|
||||
@@ -1072,6 +1072,7 @@ fn __hemx_lower_html(html: &str, table: &[(&str, &str, u32)]) -> ::std::string::
|
||||
out = __hemx_replace_attr(out, attr, name, runtime_attr, *id);
|
||||
}
|
||||
out = __hemx_lower_static_attr(out, "data-hemx-key", "data-key");
|
||||
out = __hemx_lower_static_attr(out, "h-key", "data-key");
|
||||
__hemx_inject_handle_inputs(out)
|
||||
}
|
||||
|
||||
@@ -4586,11 +4587,11 @@ mod hemplate {{
|
||||
}}
|
||||
{generated}
|
||||
fn main() {{
|
||||
let html = todo::lower_html(r#"<form data-hemx-handle="create"><input name="title"></form><li data-hemx-slot="row" data-hemx-key="7"></li>"#);
|
||||
let html = todo::lower_html(r#"<form data-hemx-handle="create"><input name="title"></form><li data-hemx-slot="row" h-key="7"></li>"#);
|
||||
assert!(html.contains(r#"data-hid="#));
|
||||
assert!(html.contains(r#"name="__h""#));
|
||||
assert!(html.contains(r#"data-key="7""#));
|
||||
assert!(!html.contains("data-hemx-key"));
|
||||
assert!(html.contains(r#"data-key="7""#)); // req: list/002 test
|
||||
assert!(!html.contains("h-key"));
|
||||
}}
|
||||
"###,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user