wip: more tweaks
This commit is contained in:
1 parent
d8aa9f032a
commit
8e18a223e3
3 files changed
+11
-20
No files matched your search
+10
-18
@@ -272,7 +272,7 @@ impl<'b> VirtualDom {
|
|||||||
use DynamicNode::*;
|
use DynamicNode::*;
|
||||||
match node {
|
match node {
|
||||||
Text(text) => self.create_dynamic_text(template, text, idx),
|
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),
|
Component(component) => self.create_component_node(template, component, idx),
|
||||||
Fragment(frag) => frag.iter().map(|child| self.create(child)).sum(),
|
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() } {
|
match unsafe { self.run_scope(scope).extend_lifetime_ref() } {
|
||||||
Ready(t) => self.mount_component(scope, template, t, idx),
|
Ready(t) => self.mount_component(scope, template, t, idx),
|
||||||
Aborted(t) => self.mount_aborted(template, t),
|
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"
|
/// 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 {
|
fn load_scope_from_vcomponent(&mut self, component: &VComponent) -> ScopeId {
|
||||||
component
|
component
|
||||||
@@ -420,15 +410,17 @@ impl<'b> VirtualDom {
|
|||||||
0
|
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
|
/// Take the rendered nodes from a component and handle them if they were async
|
||||||
///
|
///
|
||||||
/// IE simply assign an ID to the placeholder
|
/// IE simply assign an ID to the placeholder
|
||||||
fn mount_component_placeholder(
|
fn mount_async(&mut self, template: &VNode, idx: usize, scope: ScopeId) -> usize {
|
||||||
&mut self,
|
|
||||||
template: &VNode,
|
|
||||||
idx: usize,
|
|
||||||
scope: ScopeId,
|
|
||||||
) -> usize {
|
|
||||||
let new_id = self.next_element(template, template.template.node_paths[idx]);
|
let new_id = self.next_element(template, template.template.node_paths[idx]);
|
||||||
|
|
||||||
// Set the placeholder of the scope
|
// Set the placeholder of the scope
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ impl<'a> ComponentReturn<'a> for Element<'a> {
|
|||||||
fn into_return(self, _cx: &ScopeState) -> RenderReturn<'a> {
|
fn into_return(self, _cx: &ScopeState) -> RenderReturn<'a> {
|
||||||
match self {
|
match self {
|
||||||
Some(node) => RenderReturn::Ready(node),
|
Some(node) => RenderReturn::Ready(node),
|
||||||
None => RenderReturn::Aborted(VPlaceholder::default()),
|
None => RenderReturn::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ use futures_util::FutureExt;
|
|||||||
use std::{
|
use std::{
|
||||||
mem,
|
mem,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
rc::Rc,
|
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user