Quellcode durchsuchen

wip: it works more

Jonathan Kelley vor 2 Jahren
Ursprung
Commit
ea7ab5f765
4 geänderte Dateien mit 20 neuen und 18 gelöschten Zeilen
  1. 2 2
      examples/file_explorer.rs
  2. 0 6
      examples/simple_list.rs
  3. 9 6
      examples/svg.rs
  4. 9 4
      packages/core/src/create.rs

+ 2 - 2
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 {

+ 0 - 6
examples/simple_list.rs

@@ -17,12 +17,6 @@ fn app(cx: Scope) -> Element {
                 .collect::<Vec<_>>()
                 .into_iter(),
 
-            ["x", "y", "z"]
-                .into_iter()
-                .map(|f| rsx! { "{f}" })
-                .collect::<Vec<_>>()
-                .into_iter(),
-
             // Use optionals
             Some(rsx! { "Some" }),
         }

+ 9 - 6
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! {

+ 9 - 4
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
             }
         }
     }