chore: dynamic attributes cleanup

This commit is contained in:
Jonathan Kelley committed 2022-11-27 00:22:39 -05:00
1 parent bffb2644a3
commit 399169800d
6 files changed
+130 -61

No files matched your search

+38 -9
View File
@@ -1,4 +1,4 @@
use crate::{nodes::VNode, virtual_dom::VirtualDom};
use crate::{nodes::VNode, virtual_dom::VirtualDom, Mutations, ScopeId};
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -21,7 +21,7 @@ impl ElementRef {
}
}
impl VirtualDom {
impl<'b> VirtualDom {
pub fn next_element(&mut self, template: &VNode, path: &'static [u8]) -> ElementId {
let entry = self.elements.vacant_entry();
let id = entry.key();
@@ -39,11 +39,40 @@ impl VirtualDom {
pub fn cleanup_element(&mut self, id: ElementId) {
self.elements.remove(id.0);
}
pub fn drop_scope(&mut self, id: ScopeId) {
// let scope = self.scopes.get(id.0).unwrap();
// let root = scope.root_node();
// let root = unsafe { std::mem::transmute(root) };
// self.drop_template(root, false);
todo!()
}
pub fn reclaim(&mut self, el: ElementId) {
assert_ne!(el, ElementId(0));
self.elements.remove(el.0);
}
pub fn drop_template(
&mut self,
mutations: &mut Mutations,
template: &'b VNode<'b>,
gen_roots: bool,
) {
// for node in template.dynamic_nodes.iter() {
// match node {
// DynamicNode::Text { id, .. } => {}
// DynamicNode::Component { .. } => {
// todo!()
// }
// DynamicNode::Fragment { inner, nodes } => {}
// DynamicNode::Placeholder(_) => todo!(),
// _ => todo!(),
// }
// }
}
}
/*
now......
an ID is mostly a pointer to a node in the real dom.
We need to
*/