From ea7ab5f7654354f99e8b717a195d3864340802c6 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Tue, 15 Nov 2022 23:59:19 -0800 Subject: [PATCH] wip: it works more --- examples/file_explorer.rs | 4 ++-- examples/simple_list.rs | 6 ------ examples/svg.rs | 15 +++++++++------ packages/core/src/create.rs | 13 +++++++++---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/examples/file_explorer.rs b/examples/file_explorer.rs index e0acb4ae..16b3b5fa 100644 --- a/examples/file_explorer.rs +++ b/examples/file_explorer.rs @@ -21,7 +21,7 @@ fn main() { fn app(cx: Scope) -> Element { let files = use_ref(&cx, Files::new); - render! { + cx.render(rsx! { div { link { href:"https://fonts.googleapis.com/icon?family=Material+Icons", rel:"stylesheet", } style { include_str!("./assets/fileexplorer.css") } @@ -62,7 +62,7 @@ fn app(cx: Scope) -> Element { }) } } - } + }) } struct Files { diff --git a/examples/simple_list.rs b/examples/simple_list.rs index ae90c538..f0d2827d 100644 --- a/examples/simple_list.rs +++ b/examples/simple_list.rs @@ -17,12 +17,6 @@ fn app(cx: Scope) -> Element { .collect::>() .into_iter(), - ["x", "y", "z"] - .into_iter() - .map(|f| rsx! { "{f}" }) - .collect::>() - .into_iter(), - // Use optionals Some(rsx! { "Some" }), } diff --git a/examples/svg.rs b/examples/svg.rs index 2e9d6c75..631a3803 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -70,12 +70,15 @@ pub fn Die<'a>(cx: Scope<'a, DieProps<'a>>) -> Element { .map(|((x, y), _)| { let dcx = x * OFFSET; let dcy = y * OFFSET; - rsx!(circle { - cx: "{dcx}", - cy: "{dcy}", - r: "{DOT_RADIUS}", - fill: "#333" - }) + + rsx! { + circle { + cx: "{dcx}", + cy: "{dcy}", + r: "{DOT_RADIUS}", + fill: "#333" + } + } }); cx.render(rsx! { diff --git a/packages/core/src/create.rs b/packages/core/src/create.rs index 2ede165f..9be9011d 100644 --- a/packages/core/src/create.rs +++ b/packages/core/src/create.rs @@ -220,7 +220,7 @@ impl VirtualDom { path: &template.template.node_paths[idx][1..], value, }); - 1 + 0 } DynamicNode::Component { @@ -296,10 +296,15 @@ impl VirtualDom { .fold(0, |acc, child| acc + self.create(mutations, child)) } - DynamicNode::Placeholder(_) => { + DynamicNode::Placeholder(slot) => { let id = self.next_element(template); - mutations.push(CreatePlaceholder { id }); - 1 + slot.set(id); + mutations.push(AssignId { + path: &template.template.node_paths[idx][1..], + id, + }); + + 0 } } }