Explorar el Código

wip: more tweaks

Jonathan Kelley hace 2 años
padre
commit
8e18a223e3
Se han modificado 3 ficheros con 11 adiciones y 20 borrados
  1. 10 18
      packages/core/src/create.rs
  2. 1 1
      packages/core/src/nodes.rs
  3. 0 1
      packages/core/src/scope_arena.rs

+ 10 - 18
packages/core/src/create.rs

@@ -272,7 +272,7 @@ impl<'b> VirtualDom {
         use DynamicNode::*;
         match node {
             Text(text) => self.create_dynamic_text(template, text, idx),
-            Placeholder(frag) => self.create_placeholder(frag, template, idx),
+            Placeholder(place) => self.create_placeholder(place, template, idx),
             Component(component) => self.create_component_node(template, component, idx),
             Fragment(frag) => frag.iter().map(|child| self.create(child)).sum(),
         }
@@ -340,20 +340,10 @@ impl<'b> VirtualDom {
         match unsafe { self.run_scope(scope).extend_lifetime_ref() } {
             Ready(t) => self.mount_component(scope, template, t, idx),
             Aborted(t) => self.mount_aborted(template, t),
-            Async(_) => self.mount_component_placeholder(template, idx, scope),
+            Async(_) => self.mount_async(template, idx, scope),
         }
     }
 
-    fn mount_aborted(&mut self, parent: &'b VNode<'b>, placeholder: &VPlaceholder) -> usize {
-        let id = self.next_element(parent, &[]);
-
-        self.mutations.push(Mutation::CreatePlaceholder { id });
-
-        placeholder.id.set(Some(id));
-
-        1
-    }
-
     /// Load a scope from a vcomponent. If the props don't exist, that means the component is currently "live"
     fn load_scope_from_vcomponent(&mut self, component: &VComponent) -> ScopeId {
         component
@@ -420,15 +410,17 @@ impl<'b> VirtualDom {
         0
     }
 
+    fn mount_aborted(&mut self, parent: &'b VNode<'b>, placeholder: &VPlaceholder) -> usize {
+        let id = self.next_element(parent, &[]);
+        self.mutations.push(Mutation::CreatePlaceholder { id });
+        placeholder.id.set(Some(id));
+        1
+    }
+
     /// Take the rendered nodes from a component and handle them if they were async
     ///
     /// IE simply assign an ID to the placeholder
-    fn mount_component_placeholder(
-        &mut self,
-        template: &VNode,
-        idx: usize,
-        scope: ScopeId,
-    ) -> usize {
+    fn mount_async(&mut self, template: &VNode, idx: usize, scope: ScopeId) -> usize {
         let new_id = self.next_element(template, template.template.node_paths[idx]);
 
         // Set the placeholder of the scope

+ 1 - 1
packages/core/src/nodes.rs

@@ -430,7 +430,7 @@ impl<'a> ComponentReturn<'a> for Element<'a> {
     fn into_return(self, _cx: &ScopeState) -> RenderReturn<'a> {
         match self {
             Some(node) => RenderReturn::Ready(node),
-            None => RenderReturn::Aborted(VPlaceholder::default()),
+            None => RenderReturn::default(),
         }
     }
 }

+ 0 - 1
packages/core/src/scope_arena.rs

@@ -13,7 +13,6 @@ use futures_util::FutureExt;
 use std::{
     mem,
     pin::Pin,
-    rc::Rc,
     sync::Arc,
     task::{Context, Poll},
 };