restore drop scope
This commit is contained in:
1 parent
efd301a878
commit
a1676537ad
4 files changed
+25
-68
No files matched your search
@@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{innerlude::DirtyScope, nodes::VNode, virtual_dom::VirtualDom, ScopeId};
|
||||||
nodes::VNode, virtual_dom::VirtualDom, DynamicNode,
|
|
||||||
ScopeId,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// An Element's unique identifier.
|
/// An Element's unique identifier.
|
||||||
///
|
///
|
||||||
@@ -60,37 +57,13 @@ impl VirtualDom {
|
|||||||
// Drop a scope and all its children
|
// Drop a scope and all its children
|
||||||
//
|
//
|
||||||
// Note: This will not remove any ids from the arena
|
// Note: This will not remove any ids from the arena
|
||||||
pub(crate) fn drop_scope(&mut self, _id: ScopeId, _recursive: bool) {
|
pub(crate) fn drop_scope(&mut self, id: ScopeId) {
|
||||||
// todo: Do we need this now that we don't have a bunch of unsafe code?
|
self.dirty_scopes.remove(&DirtyScope {
|
||||||
// self.dirty_scopes.remove(&DirtyScope {
|
height: self.scopes[id.0].height(),
|
||||||
// height: self.scopes[id.0].height(),
|
id,
|
||||||
// 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(_) => {}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.scopes.remove(id.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1000,8 +1000,8 @@ impl VirtualDom {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Now drop all the resouces
|
// Now drop all the resources
|
||||||
self.drop_scope(scope, false);
|
self.drop_scope(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_first_element(&self, node: &VNode) -> ElementId {
|
fn find_first_element(&self, node: &VNode) -> ElementId {
|
||||||
|
|||||||
+14
-30
@@ -359,14 +359,14 @@ pub struct VComponent {
|
|||||||
pub(crate) props: BoxedAnyProps,
|
pub(crate) props: BoxedAnyProps,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VComponent {
|
impl VComponent {
|
||||||
/// Get the scope that this component is mounted to
|
/// Get the scope that this component is mounted to
|
||||||
pub fn mounted_scope(&self) -> Option<ScopeId> {
|
pub fn mounted_scope(&self) -> Option<ScopeId> {
|
||||||
self.scope.get()
|
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 {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
f.debug_struct("VComponent")
|
f.debug_struct("VComponent")
|
||||||
.field("name", &self.name)
|
.field("name", &self.name)
|
||||||
@@ -385,7 +385,7 @@ pub struct VText {
|
|||||||
pub(crate) id: Cell<Option<ElementId>>,
|
pub(crate) id: Cell<Option<ElementId>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VText {
|
impl VText {
|
||||||
/// Create a new VText
|
/// Create a new VText
|
||||||
pub fn new(value: String) -> Self {
|
pub fn new(value: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -522,22 +522,6 @@ pub enum AttributeValue {
|
|||||||
|
|
||||||
pub type ListenerCb = Box<dyn FnMut(Event<dyn Any>)>;
|
pub type ListenerCb = Box<dyn FnMut(Event<dyn Any>)>;
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
fn serialize_any_value<S>(_: &std::cell::Ref<'_, dyn AnyValue>, _: S) -> Result<S::Ok, S::Error>
|
|
||||||
where
|
|
||||||
S: serde::Serializer,
|
|
||||||
{
|
|
||||||
panic!("Any cannot be serialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
fn deserialize_any_value<'de, 'a, D>(_: D) -> Result<std::cell::Ref<'a, dyn AnyValue>, D::Error>
|
|
||||||
where
|
|
||||||
D: serde::Deserializer<'de>,
|
|
||||||
{
|
|
||||||
panic!("Any cannot be deserialized")
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::fmt::Debug for AttributeValue {
|
impl std::fmt::Debug for AttributeValue {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
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 {
|
fn into_dyn_node(self) -> DynamicNode {
|
||||||
DynamicNode::Text(VText {
|
DynamicNode::Text(VText {
|
||||||
value: self.to_string(),
|
value: self.to_string(),
|
||||||
@@ -668,12 +652,12 @@ impl IntoDynNode for &VNode {
|
|||||||
pub trait IntoVNode {
|
pub trait IntoVNode {
|
||||||
fn into_vnode(self) -> VNode;
|
fn into_vnode(self) -> VNode;
|
||||||
}
|
}
|
||||||
impl<'a> IntoVNode for VNode {
|
impl IntoVNode for VNode {
|
||||||
fn into_vnode(self) -> VNode {
|
fn into_vnode(self) -> VNode {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> IntoVNode for Element {
|
impl IntoVNode for Element {
|
||||||
fn into_vnode(self) -> VNode {
|
fn into_vnode(self) -> VNode {
|
||||||
match self {
|
match self {
|
||||||
Some(val) => val.into_vnode(),
|
Some(val) => val.into_vnode(),
|
||||||
@@ -706,43 +690,43 @@ pub trait IntoAttributeValue {
|
|||||||
fn into_value(self) -> AttributeValue;
|
fn into_value(self) -> AttributeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for AttributeValue {
|
impl IntoAttributeValue for AttributeValue {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for &'a str {
|
impl IntoAttributeValue for &str {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Text(self.to_string())
|
AttributeValue::Text(self.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for String {
|
impl IntoAttributeValue for String {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Text(self)
|
AttributeValue::Text(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for f64 {
|
impl IntoAttributeValue for f64 {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Float(self)
|
AttributeValue::Float(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for i64 {
|
impl IntoAttributeValue for i64 {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Int(self)
|
AttributeValue::Int(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for bool {
|
impl IntoAttributeValue for bool {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Bool(self)
|
AttributeValue::Bool(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> IntoAttributeValue for Arguments<'_> {
|
impl IntoAttributeValue for Arguments<'_> {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
AttributeValue::Text(self.to_string())
|
AttributeValue::Text(self.to_string())
|
||||||
}
|
}
|
||||||
@@ -754,7 +738,7 @@ impl IntoAttributeValue for Box<dyn AnyValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: IntoAttributeValue> IntoAttributeValue for Option<T> {
|
impl<T: IntoAttributeValue> IntoAttributeValue for Option<T> {
|
||||||
fn into_value(self) -> AttributeValue {
|
fn into_value(self) -> AttributeValue {
|
||||||
match self {
|
match self {
|
||||||
Some(val) => val.into_value(),
|
Some(val) => val.into_value(),
|
||||||
|
|||||||
@@ -597,7 +597,7 @@ impl VirtualDom {
|
|||||||
|
|
||||||
self.wait_for_work().await;
|
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 {
|
impl Drop for VirtualDom {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Simply drop this scope which drops all of its children
|
// Simply drop this scope which drops all of its children
|
||||||
self.drop_scope(ScopeId::ROOT, true);
|
self.drop_scope(ScopeId::ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user