update vnode ptr when parent of component reruns
This commit is contained in:
1 parent
cfc6887e34
commit
d26aa95bcd
3 files changed
+17
-7
No files matched your search
@@ -78,7 +78,7 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn update_template(&mut self, el: ElementId, node: &VNode) {
|
pub(crate) fn update_template(&mut self, el: ElementId, node: *const VNode) {
|
||||||
let bubble_id = self.elements[el.0].unwrap();
|
let bubble_id = self.elements[el.0].unwrap();
|
||||||
self.update_template_bubble(bubble_id, node)
|
self.update_template_bubble(bubble_id, node)
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
c.props.take();
|
c.props.take();
|
||||||
if let Some(bubble_id) = c.bubble_id.get() {
|
if let Some(bubble_id) = c.bubble_id.get() {
|
||||||
self.element_refs.remove(bubble_id.0);
|
self.element_refs.try_remove(bubble_id.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DynamicNode::Fragment(nodes) => {
|
DynamicNode::Fragment(nodes) => {
|
||||||
|
|||||||
@@ -547,6 +547,7 @@ impl<'b> VirtualDom {
|
|||||||
// Create the component's root element
|
// Create the component's root element
|
||||||
Ready(t) => {
|
Ready(t) => {
|
||||||
self.assign_boundary_ref(parent, t);
|
self.assign_boundary_ref(parent, t);
|
||||||
|
component.bubble_id.set(t.parent.get());
|
||||||
self.create_scope(scope, t)
|
self.create_scope(scope, t)
|
||||||
}
|
}
|
||||||
Aborted(t) => self.mount_aborted(t, parent),
|
Aborted(t) => self.mount_aborted(t, parent),
|
||||||
|
|||||||
@@ -174,7 +174,9 @@ impl<'b> VirtualDom {
|
|||||||
(Fragment(left), Fragment(right)) => self.diff_non_empty_fragment(left, right, parent),
|
(Fragment(left), Fragment(right)) => self.diff_non_empty_fragment(left, right, parent),
|
||||||
(Placeholder(left), Placeholder(right)) => {
|
(Placeholder(left), Placeholder(right)) => {
|
||||||
right.id.set(left.id.get());
|
right.id.set(left.id.get());
|
||||||
right.parent.set(left.parent.get())
|
right.parent.set(left.parent.get());
|
||||||
|
// Update the template
|
||||||
|
self.update_template(left.id.get().unwrap(), parent.template);
|
||||||
},
|
},
|
||||||
(Component(left), Component(right)) => self.diff_vcomponent(left, right, Some(parent)),
|
(Component(left), Component(right)) => self.diff_vcomponent(left, right, Some(parent)),
|
||||||
(Placeholder(left), Fragment(right)) => self.replace_placeholder(left, *right, parent),
|
(Placeholder(left), Fragment(right)) => self.replace_placeholder(left, *right, parent),
|
||||||
@@ -214,10 +216,7 @@ impl<'b> VirtualDom {
|
|||||||
let scope_id = left.scope.get().unwrap();
|
let scope_id = left.scope.get().unwrap();
|
||||||
|
|
||||||
right.scope.set(Some(scope_id));
|
right.scope.set(Some(scope_id));
|
||||||
if let Some(bubble_id) = left.bubble_id.get() {
|
right.bubble_id.set(left.bubble_id.get());
|
||||||
right.bubble_id.set(Some(bubble_id));
|
|
||||||
self.update_template_bubble(bubble_id, parent.unwrap().template);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy out the box for both
|
// copy out the box for both
|
||||||
let old = self.scopes[scope_id.0].props.as_ref();
|
let old = self.scopes[scope_id.0].props.as_ref();
|
||||||
@@ -236,6 +235,16 @@ impl<'b> VirtualDom {
|
|||||||
|
|
||||||
// Now run the component and diff it
|
// Now run the component and diff it
|
||||||
self.run_scope(scope_id);
|
self.run_scope(scope_id);
|
||||||
|
if let Some(bubble_id) = right.bubble_id.get() {
|
||||||
|
if let RenderReturn::Ready(new_node) = unsafe {
|
||||||
|
self.scopes[scope_id.0]
|
||||||
|
.current_frame()
|
||||||
|
.try_load_node()
|
||||||
|
.expect("Call rebuild before diffing")
|
||||||
|
} {
|
||||||
|
self.update_template_bubble(bubble_id, new_node);
|
||||||
|
}
|
||||||
|
}
|
||||||
self.diff_scope(scope_id);
|
self.diff_scope(scope_id);
|
||||||
|
|
||||||
self.dirty_scopes.remove(&DirtyScope {
|
self.dirty_scopes.remove(&DirtyScope {
|
||||||
|
|||||||
Reference in new issue
Block a user