From 8e18a223e3971b2d7174465f7e20dc4a13c8027b Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Fri, 23 Dec 2022 19:43:19 -0500 Subject: [PATCH] wip: more tweaks --- packages/core/src/create.rs | 28 ++++++++++------------------ packages/core/src/nodes.rs | 2 +- packages/core/src/scope_arena.rs | 1 - 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/core/src/create.rs b/packages/core/src/create.rs index 3cbfe9440..4e7e35a1f 100644 --- a/packages/core/src/create.rs +++ b/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 diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 8e7a372af..91e6d0c0c 100644 --- a/packages/core/src/nodes.rs +++ b/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(), } } } diff --git a/packages/core/src/scope_arena.rs b/packages/core/src/scope_arena.rs index dc9158520..6d946d3d9 100644 --- a/packages/core/src/scope_arena.rs +++ b/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}, };