diff --git a/AGENTS.md b/AGENTS.md index 98e1b57..826e374 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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. diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index 9f5f29e..05c7d84 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -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] diff --git a/hemx-build/src/lib.rs b/hemx-build/src/lib.rs index 8799dd2..8f89e17 100644 --- a/hemx-build/src/lib.rs +++ b/hemx-build/src/lib.rs @@ -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#"
  • "#); + let html = todo::lower_html(r#"
  • "#); 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")); }} "###, );