♻️ (pagetop): Props::unpack() exige &mut Context

This commit is contained in:
Manuel Cillero 2026-09-08 07:28:50 +02:00
parent ee1b48ff3f
commit 8577ca8a59
14 changed files with 280 additions and 190 deletions

View file

@ -275,9 +275,9 @@ async fn props_styles_renders_style_attribute() {
let p = Props::default()
.with_prop(PropsOp::add_style("color", "red"))
.with_prop(PropsOp::add_style("font-weight", "bold"));
let cx = Context::default();
let mut cx = Context::default();
assert_eq!(
html! { button (p.unpack(&cx)) { "OK" } }.into_string(),
html! { button (p.unpack(&mut cx)) { "OK" } }.into_string(),
r#"<button style="color: red; font-weight: bold">OK</button>"#
);
}
@ -289,9 +289,9 @@ async fn props_styles_render_after_class_and_before_other_attrs() {
.with_prop(PropsOp::add_classes("btn"))
.with_prop(PropsOp::add_style("color", "red"))
.with_prop(PropsOp::set("data-x", "1"));
let cx = Context::default();
let mut cx = Context::default();
assert_eq!(
html! { button (p.unpack(&cx)) { "OK" } }.into_string(),
html! { button (p.unpack(&mut cx)) { "OK" } }.into_string(),
r#"<button id="main" class="btn" style="color: red" data-x="1">OK</button>"#
);
}
@ -299,9 +299,9 @@ async fn props_styles_render_after_class_and_before_other_attrs() {
#[pagetop::test]
async fn props_styles_escapes_double_quotes_in_value() {
let p = Props::default().with_prop(PropsOp::add_style("content", r#""hi""#));
let cx = Context::default();
let mut cx = Context::default();
assert_eq!(
html! { span (p.unpack(&cx)) {} }.into_string(),
html! { span (p.unpack(&mut cx)) {} }.into_string(),
r#"<span style="content: &quot;hi&quot;"></span>"#
);
}