feat: fix the scope rollover bug

This commit is contained in:
Jonathan Kelley committed 2022-12-12 18:31:30 -08:00
1 parent e4d089fabc
commit d4b6bb8a7b
17 files changed
+591 -360

No files matched your search

+7 -7
View File
@@ -34,14 +34,14 @@ impl ElementRef {
impl VirtualDom {
pub(crate) fn next_element(&mut self, template: &VNode, path: &'static [u8]) -> ElementId {
self.next(template, ElementPath::Deep(path))
self.next_reference(template, ElementPath::Deep(path))
}
pub(crate) fn next_root(&mut self, template: &VNode, path: usize) -> ElementId {
self.next(template, ElementPath::Root(path))
self.next_reference(template, ElementPath::Root(path))
}
fn next(&mut self, template: &VNode, path: ElementPath) -> ElementId {
fn next_reference(&mut self, template: &VNode, path: ElementPath) -> ElementId {
let entry = self.elements.vacant_entry();
let id = entry.key();
@@ -100,15 +100,15 @@ impl VirtualDom {
nodes.iter().for_each(|node| self.drop_scope_inner(node))
}
DynamicNode::Placeholder(t) => {
self.try_reclaim(t.get());
self.try_reclaim(t.id.get().unwrap());
}
DynamicNode::Text(t) => {
self.try_reclaim(t.id.get());
self.try_reclaim(t.id.get().unwrap());
}
});
for root in node.root_ids {
let id = root.get();
let id = root.get().unwrap();
if id.0 != 0 {
self.try_reclaim(id);
}
@@ -132,7 +132,7 @@ impl VirtualDom {
// Only descend if the props are borrowed
DynamicNode::Component(c) if !c.static_props => {
self.ensure_drop_safety(c.scope.get().unwrap());
c.props.set(None);
c.props.take();
}
DynamicNode::Fragment(f) => f