Preserve native interaction semantics

This commit is contained in:
tmk241
2026-09-01 09:21:23 +02:00
parent 3323aaecd6
commit 53f0a5db1a
11 changed files with 135 additions and 115 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ Complete server-rendered pages can be inspected directly:
```rust
let page = hemx_test::inspect_html_document(
"<!doctype html><html><body><main id=app data-sid=7>Ready</main></body></html>",
"<!doctype html><html><body><main id=app data-hemx-resource=7>Ready</main></body></html>",
);
page.assert_text("main#app", "Ready");
# use hemx_core::{GeneratedTarget, ResourceId, Slot};
+5 -5
View File
@@ -101,7 +101,7 @@ impl HtmlInspector {
/// Select elements carrying the runtime marker for a typed handle.
pub fn select_handle<I>(&self, handle: Handle<I>) -> HtmlSelection {
self.selection_or_panic(&attribute_selector("data-hid", &handle.to_string()))
self.selection_or_panic(&attribute_selector("data-hemx-action", &handle.to_string()))
}
/// Assert that rendered HTML contains a typed handle marker.
@@ -299,10 +299,10 @@ impl Error for HtmlInspectionError {}
fn resource_attribute(kind: ResourceKind) -> &'static str {
match kind {
ResourceKind::Slot => "data-sid",
ResourceKind::Atom => "data-aid",
ResourceKind::Handle => "data-hid",
ResourceKind::Form => "data-fid",
ResourceKind::Slot => "data-hemx-resource",
ResourceKind::Atom => "data-hemx-resource",
ResourceKind::Handle => "data-hemx-action",
ResourceKind::Form => "data-hemx-resource",
}
}
+1 -1
View File
@@ -403,7 +403,7 @@ impl EffectInspector {
/// Assert that generated keyed-row metadata for a key is absent from payloads.
pub fn payload_excludes_key(&self, key: impl ToString) -> bool {
self.payload_excludes(&format!("data-key=\"{}\"", key.to_string()))
self.payload_excludes(&format!("data-hemx-key=\"{}\"", key.to_string()))
}
/// Return HTML for a generated target containing text, without exposing raw payloads.
+4 -4
View File
@@ -49,7 +49,7 @@ fn inspects_generated_targets_and_handles_without_raw_runtime_ids() {
let target = TestTarget(ResourceKind::Slot, 42);
let handle = hemx_core::Handle::<()>::new(7);
let inspected = hemx_test::inspect_html_fragment(
r#"<section data-sid="42"><button data-hid="7">Save</button></section>"#,
r#"<section data-hemx-resource="42"><button data-hemx-action="7">Save</button></section>"#,
);
inspected.assert_target(target);
@@ -100,7 +100,7 @@ fn inspects_generated_target_document_and_fragment_payloads() {
Effect::Insert {
target: ResourceRef::unscoped(ResourceId::new(ResourceKind::Slot, 2)),
position: InsertPosition::Last,
html: SafeHtml::trusted("<li data-key=later>later</li>"),
html: SafeHtml::trusted("<li data-hemx-key=later>later</li>"),
},
"Insert",
),
@@ -108,7 +108,7 @@ fn inspects_generated_target_document_and_fragment_payloads() {
Effect::Insert {
target: ResourceRef::unscoped(ResourceId::new(ResourceKind::Slot, 2)),
position: InsertPosition::First,
html: SafeHtml::trusted("<li data-key=first>first</li>"),
html: SafeHtml::trusted("<li data-hemx-key=first>first</li>"),
},
"Insert",
),
@@ -116,7 +116,7 @@ fn inspects_generated_target_document_and_fragment_payloads() {
let fragment = hemx_test::inspect(effect)
.target_html_fragment(TestTarget(ResourceKind::Slot, 2))
.unwrap();
fragment.assert_count("li[data-key]", 1);
fragment.assert_count("li[data-hemx-key]", 1);
assert!(fragment.origin().contains(operation));
}
}
+2 -2
View File
@@ -136,7 +136,7 @@ fn inspector_predicates_bind_operation_target_scope_kind_and_payload() {
Effect::Patch {
target: keyed_ref.clone(),
mode: PatchMode::Replace,
html: SafeHtml::trusted("<li data-key=\"row-1\">replacement</li>"),
html: SafeHtml::trusted("<li data-hemx-key=\"row-1\">replacement</li>"),
},
Effect::Insert {
target: ResourceRef::unscoped(resource),
@@ -202,7 +202,7 @@ fn inspector_predicates_bind_operation_target_scope_kind_and_payload() {
assert!(!inspected.payload_excludes_key("row-1"));
assert_eq!(
inspected.target_html_containing(expected, "replacement"),
Some("<li data-key=\"row-1\">replacement</li>")
Some("<li data-hemx-key=\"row-1\">replacement</li>")
);
assert_eq!(
inspected.target_html_containing(expected, "inserted"),