From e1bec2fae535f8cf6f36bc95ebbece344d9403d6 Mon Sep 17 00:00:00 2001 From: Lukas Potthast Date: Fri, 5 Apr 2024 17:44:45 +0200 Subject: [PATCH] Use IntoAttribute; Simplify --- examples/spread/src/lib.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/spread/src/lib.rs b/examples/spread/src/lib.rs index 81def00abf..bdf9f42b97 100644 --- a/examples/spread/src/lib.rs +++ b/examples/spread/src/lib.rs @@ -7,27 +7,25 @@ pub fn SpreadingExample() -> impl IntoView { let _ = window().alert_with_message(msg.as_ref()); } - let attrs_only: Vec<(&'static str, Attribute)> = vec![ - ("data-foo", Attribute::String(Oco::Borrowed("42"))), - ("aria-disabled", Attribute::String(Oco::Borrowed("false"))), - ]; + let attrs_only: Vec<(&'static str, Attribute)> = + vec![("data-foo", "42".into_attribute())]; let event_handlers_only: Vec = vec![EventHandlerFn::Click(Box::new(|_e: ev::MouseEvent| { alert("event_handlers_only clicked"); }))]; - let mixed: Vec = vec![ - ("data-foo", Attribute::String(Oco::Borrowed("123"))).into(), - ("aria-disabled", Attribute::String(Oco::Borrowed("true"))).into(), + let combined: Vec = vec![ + ("data-foo", "123".into_attribute()).into(), EventHandlerFn::Click(Box::new(|_e: ev::MouseEvent| { - alert("mixed clicked"); + alert("combined clicked"); })) .into(), ]; let partial_attrs: Vec<(&'static str, Attribute)> = - vec![("data-foo", Attribute::String(Oco::Borrowed("11")))]; + vec![("data-foo", "11".into_attribute())]; + let partial_event_handlers: Vec = vec![EventHandlerFn::Click(Box::new(|_e: ev::MouseEvent| { alert("partial_event_handlers clicked"); @@ -42,8 +40,8 @@ pub fn SpreadingExample() -> impl IntoView { "
"
-
- "
" +
+ "
"