Merge branch 'DioxusLabs:master' into fix-borrowed-props
This commit is contained in:
19 files changed
+220
-84
No files matched your search
@@ -87,8 +87,12 @@ impl<'b> VirtualDom {
|
||||
}
|
||||
}
|
||||
|
||||
// Intialize the root nodes slice
|
||||
*node.root_ids.borrow_mut() = vec![ElementId(0); node.template.get().roots.len()];
|
||||
// Initialize the root nodes slice
|
||||
{
|
||||
let mut nodes_mut = node.root_ids.borrow_mut();
|
||||
let len = node.template.get().roots.len();
|
||||
nodes_mut.resize(len, ElementId::default());
|
||||
};
|
||||
|
||||
// The best renderers will have templates prehydrated and registered
|
||||
// Just in case, let's create the template using instructions anyways
|
||||
|
||||
@@ -15,6 +15,7 @@ use DynamicNode::*;
|
||||
|
||||
impl<'b> VirtualDom {
|
||||
pub(super) fn diff_scope(&mut self, scope: ScopeId) {
|
||||
self.runtime.scope_stack.borrow_mut().push(scope);
|
||||
let scope_state = &mut self.get_scope(scope).unwrap();
|
||||
unsafe {
|
||||
// Load the old and new bump arenas
|
||||
@@ -45,6 +46,7 @@ impl<'b> VirtualDom {
|
||||
(Aborted(l), Ready(r)) => self.replace_placeholder(l, [r]),
|
||||
};
|
||||
}
|
||||
self.runtime.scope_stack.borrow_mut().pop();
|
||||
}
|
||||
|
||||
fn diff_ok_to_err(&mut self, l: &'b VNode<'b>, p: &'b VPlaceholder) {
|
||||
@@ -126,7 +128,13 @@ impl<'b> VirtualDom {
|
||||
});
|
||||
|
||||
// Make sure the roots get transferred over while we're here
|
||||
*right_template.root_ids.borrow_mut() = left_template.root_ids.borrow().clone();
|
||||
{
|
||||
let mut right = right_template.root_ids.borrow_mut();
|
||||
right.clear();
|
||||
for &element in left_template.root_ids.borrow().iter() {
|
||||
right.push(element);
|
||||
}
|
||||
}
|
||||
|
||||
let root_ids = right_template.root_ids.borrow();
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ pub struct VNode<'a> {
|
||||
|
||||
/// The IDs for the roots of this template - to be used when moving the template around and removing it from
|
||||
/// the actual Dom
|
||||
pub root_ids: RefCell<Vec<ElementId>>,
|
||||
pub root_ids: RefCell<bumpalo::collections::Vec<'a, ElementId>>,
|
||||
|
||||
/// The dynamic parts of the template
|
||||
pub dynamic_nodes: &'a [DynamicNode<'a>],
|
||||
@@ -65,11 +65,11 @@ pub struct VNode<'a> {
|
||||
|
||||
impl<'a> VNode<'a> {
|
||||
/// Create a template with no nodes that will be skipped over during diffing
|
||||
pub fn empty() -> Element<'a> {
|
||||
pub fn empty(cx: &'a ScopeState) -> Element<'a> {
|
||||
Some(VNode {
|
||||
key: None,
|
||||
parent: None,
|
||||
root_ids: Default::default(),
|
||||
root_ids: RefCell::new(bumpalo::collections::Vec::new_in(cx.bump())),
|
||||
dynamic_nodes: &[],
|
||||
dynamic_attrs: &[],
|
||||
template: Cell::new(Template {
|
||||
@@ -698,7 +698,7 @@ impl<'a, 'b> IntoDynNode<'a> for LazyNodes<'a, 'b> {
|
||||
impl<'a, 'b> IntoDynNode<'b> for &'a str {
|
||||
fn into_vnode(self, cx: &'b ScopeState) -> DynamicNode<'b> {
|
||||
DynamicNode::Text(VText {
|
||||
value: bumpalo::collections::String::from_str_in(self, cx.bump()).into_bump_str(),
|
||||
value: cx.bump().alloc_str(self),
|
||||
id: Default::default(),
|
||||
})
|
||||
}
|
||||
@@ -741,10 +741,10 @@ impl<'a> IntoTemplate<'a> for VNode<'a> {
|
||||
}
|
||||
}
|
||||
impl<'a> IntoTemplate<'a> for Element<'a> {
|
||||
fn into_template(self, _cx: &'a ScopeState) -> VNode<'a> {
|
||||
fn into_template(self, cx: &'a ScopeState) -> VNode<'a> {
|
||||
match self {
|
||||
Some(val) => val.into_template(_cx),
|
||||
_ => VNode::empty().unwrap(),
|
||||
Some(val) => val.into_template(cx),
|
||||
_ => VNode::empty(cx).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user