|
@@ -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))]
|
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
|
|
#[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 {
|
|
pub fn next_element(&mut self, template: &VNode, path: &'static [u8]) -> ElementId {
|
|
let entry = self.elements.vacant_entry();
|
|
let entry = self.elements.vacant_entry();
|
|
let id = entry.key();
|
|
let id = entry.key();
|
|
@@ -39,11 +39,40 @@ impl VirtualDom {
|
|
pub fn cleanup_element(&mut self, id: ElementId) {
|
|
pub fn cleanup_element(&mut self, id: ElementId) {
|
|
self.elements.remove(id.0);
|
|
self.elements.remove(id.0);
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
|
|
-/*
|
|
|
|
-now......
|
|
|
|
|
|
+ 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!()
|
|
|
|
+ // }
|
|
|
|
|
|
-an ID is mostly a pointer to a node in the real dom.
|
|
|
|
-We need to
|
|
|
|
-*/
|
|
|
|
|
|
+ // DynamicNode::Fragment { inner, nodes } => {}
|
|
|
|
+ // DynamicNode::Placeholder(_) => todo!(),
|
|
|
|
+ // _ => todo!(),
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+}
|