diff --git a/packages/core/src/arena.rs b/packages/core/src/arena.rs index 1f3b67315..02e3997b6 100644 --- a/packages/core/src/arena.rs +++ b/packages/core/src/arena.rs @@ -1,7 +1,4 @@ -use crate::{ - nodes::VNode, virtual_dom::VirtualDom, DynamicNode, - ScopeId, -}; +use crate::{innerlude::DirtyScope, nodes::VNode, virtual_dom::VirtualDom, ScopeId}; /// An Element's unique identifier. /// @@ -60,37 +57,13 @@ impl VirtualDom { // Drop a scope and all its children // // Note: This will not remove any ids from the arena - pub(crate) fn drop_scope(&mut self, _id: ScopeId, _recursive: bool) { - // todo: Do we need this now that we don't have a bunch of unsafe code? - // self.dirty_scopes.remove(&DirtyScope { - // height: self.scopes[id.0].height(), - // id, - // }); - - // if recursive { - // if let Some(root) = self.scopes[id.0].try_root_node() { - // if let RenderReturn::Ready(node) = root { - // self.drop_scope_inner(node) - // } - // } - // } - - // self.scopes.remove(id.0); - } - - fn drop_scope_inner(&mut self, node: &VNode) { - node.dynamic_nodes.iter().for_each(|node| match node { - DynamicNode::Component(c) => { - if let Some(f) = c.scope.get() { - self.drop_scope(f, true); - } - } - DynamicNode::Fragment(nodes) => { - nodes.iter().for_each(|node| self.drop_scope_inner(node)) - } - DynamicNode::Placeholder(_) => {} - DynamicNode::Text(_) => {} + pub(crate) fn drop_scope(&mut self, id: ScopeId) { + self.dirty_scopes.remove(&DirtyScope { + height: self.scopes[id.0].height(), + id, }); + + self.scopes.remove(id.0); } } diff --git a/packages/core/src/diff.rs b/packages/core/src/diff.rs index 6a4d490a3..bb85211e7 100644 --- a/packages/core/src/diff.rs +++ b/packages/core/src/diff.rs @@ -1000,8 +1000,8 @@ impl VirtualDom { } }; - // Now drop all the resouces - self.drop_scope(scope, false); + // Now drop all the resources + self.drop_scope(scope); } fn find_first_element(&self, node: &VNode) -> ElementId { diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 774fe5856..8b39dad2d 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -359,14 +359,14 @@ pub struct VComponent { pub(crate) props: BoxedAnyProps, } -impl<'a> VComponent { +impl VComponent { /// Get the scope that this component is mounted to pub fn mounted_scope(&self) -> Option { self.scope.get() } } -impl<'a> std::fmt::Debug for VComponent { +impl std::fmt::Debug for VComponent { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("VComponent") .field("name", &self.name) @@ -385,7 +385,7 @@ pub struct VText { pub(crate) id: Cell>, } -impl<'a> VText { +impl VText { /// Create a new VText pub fn new(value: String) -> Self { Self { @@ -522,22 +522,6 @@ pub enum AttributeValue { pub type ListenerCb = Box)>; -#[cfg(feature = "serialize")] -fn serialize_any_value(_: &std::cell::Ref<'_, dyn AnyValue>, _: S) -> Result -where - S: serde::Serializer, -{ - panic!("Any cannot be serialized") -} - -#[cfg(feature = "serialize")] -fn deserialize_any_value<'de, 'a, D>(_: D) -> Result, D::Error> -where - D: serde::Deserializer<'de>, -{ - panic!("Any cannot be deserialized") -} - impl std::fmt::Debug for AttributeValue { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -650,7 +634,7 @@ impl IntoDynNode for String { } } -impl<'b> IntoDynNode for Arguments<'_> { +impl IntoDynNode for Arguments<'_> { fn into_dyn_node(self) -> DynamicNode { DynamicNode::Text(VText { value: self.to_string(), @@ -668,12 +652,12 @@ impl IntoDynNode for &VNode { pub trait IntoVNode { fn into_vnode(self) -> VNode; } -impl<'a> IntoVNode for VNode { +impl IntoVNode for VNode { fn into_vnode(self) -> VNode { self } } -impl<'a> IntoVNode for Element { +impl IntoVNode for Element { fn into_vnode(self) -> VNode { match self { Some(val) => val.into_vnode(), @@ -706,43 +690,43 @@ pub trait IntoAttributeValue { fn into_value(self) -> AttributeValue; } -impl<'a> IntoAttributeValue for AttributeValue { +impl IntoAttributeValue for AttributeValue { fn into_value(self) -> AttributeValue { self } } -impl<'a> IntoAttributeValue for &'a str { +impl IntoAttributeValue for &str { fn into_value(self) -> AttributeValue { AttributeValue::Text(self.to_string()) } } -impl<'a> IntoAttributeValue for String { +impl IntoAttributeValue for String { fn into_value(self) -> AttributeValue { AttributeValue::Text(self) } } -impl<'a> IntoAttributeValue for f64 { +impl IntoAttributeValue for f64 { fn into_value(self) -> AttributeValue { AttributeValue::Float(self) } } -impl<'a> IntoAttributeValue for i64 { +impl IntoAttributeValue for i64 { fn into_value(self) -> AttributeValue { AttributeValue::Int(self) } } -impl<'a> IntoAttributeValue for bool { +impl IntoAttributeValue for bool { fn into_value(self) -> AttributeValue { AttributeValue::Bool(self) } } -impl<'a> IntoAttributeValue for Arguments<'_> { +impl IntoAttributeValue for Arguments<'_> { fn into_value(self) -> AttributeValue { AttributeValue::Text(self.to_string()) } @@ -754,7 +738,7 @@ impl IntoAttributeValue for Box { } } -impl<'a, T: IntoAttributeValue> IntoAttributeValue for Option { +impl IntoAttributeValue for Option { fn into_value(self) -> AttributeValue { match self { Some(val) => val.into_value(), diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 61be42664..5053bcae7 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -597,7 +597,7 @@ impl VirtualDom { self.wait_for_work().await; - self.render_immediate(&mut NoOpMutations);; + self.render_immediate(&mut NoOpMutations); } } @@ -672,6 +672,6 @@ impl VirtualDom { impl Drop for VirtualDom { fn drop(&mut self) { // Simply drop this scope which drops all of its children - self.drop_scope(ScopeId::ROOT, true); + self.drop_scope(ScopeId::ROOT); } }