@@ -1,5 +1,5 @@
11use dodrio::bumpalo::{self, Bump};
2−use dodrio::{on, Attribute, Node, Render};
2+use dodrio::{Node, Render};
33use wasm_bindgen::prelude::*;
44use wasm_bindgen::JsCast;
55
@@ -25,48 +25,39 @@ impl SayHelloTo {
2525// The `Render` implementation has a text `<input>` and a `<div>` that shows a
2626// greeting to the `<input>`'s value.
2727impl Render for SayHelloTo {
28− fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> dodrio::Node<'bump>
28+ fn render<'a, 'bump>(&'a self, bump: &'bump Bump) -> Node<'bump>
2929 where
3030 'a: 'bump,
3131 {
32− let input = Node::element(
33− bump,
34− "input",
35− [on(bump, "input", |root, vdom, event| {
36− // If the event's target is our input...
37− let input = match event
38− .target()
39− .and_then(|t| t.dyn_into::<web_sys::HtmlInputElement>().ok())
40− {
41− None => return,
42− Some(input) => input,
43− };
32+ use dodrio::builder::*;
4433
45− // ...then get its value and update who we are greeting.
46− let value = input.value();
47− let hello = root.unwrap_mut::<SayHelloTo>();
48− hello.set_who(value);
34+ div(bump)
35+ .children([
36+ input(bump)
37+ .attr("type", "text")
38+ .attr("value", &self.who)
39+ .on("input", |root, vdom, event| {
40+ // If the event's target is our input...
41+ let input = match event
42+ .target()
43+ .and_then(|t| t.dyn_into::<web_sys::HtmlInputElement>().ok())
44+ {
45+ None => return,
46+ Some(input) => input,
47+ };
4948
50− // Finally, re-render the component on the next animation frame.
51− vdom.schedule_render();
52− })],
53− [
54− Attribute {
55− name: "type",
56− value: "text",
57− },
58− Attribute {
59− name: "value",
60− value: &self.who,
61− },
62− ],
63− [],
64− );
49+ // ...then get its value and update who we are greeting.
50+ let value = input.value();
51+ let hello = root.unwrap_mut::<SayHelloTo>();
52+ hello.set_who(value);
6553
66− let hello = bumpalo::format!(in bump, "Hello, {}!", self.who);
67− let hello = Node::text(hello.into_bump_str());
68−
69− Node::element(bump, "div", [], [], [input, hello])
54+ // Finally, re-render the component on the next animation frame.
55+ vdom.schedule_render();
56+ })
57+ .finish(),
58+ text(bumpalo::format!(in bump, "Hello, {}!", self.who).into_bump_str()),
59+ ])
60+ .finish()
7061 }
7162}
7263