wip: more modifications to templates

This commit is contained in:
Jonathan Kelley committed 2022-10-21 18:54:14 -07:00
1 parent 90982e0ccb
commit 7cbb4d52dd
16 files changed
+342 -1520

No files matched your search

+15 -1
View File
@@ -5,11 +5,13 @@
use std::fmt::{Debug, Formatter};
mod Placeholder;
mod arbitrary_value;
mod component;
mod element;
mod factory;
mod fragment;
mod placeholder;
mod suspense;
mod template;
mod text;
@@ -23,6 +25,8 @@ pub use suspense::*;
pub use template::*;
pub use text::*;
use self::Placeholder::VPlaceholder;
/// A composable "VirtualNode" to declare a User Interface in the Dioxus VirtualDOM.
///
/// VNodes are designed to be lightweight and used with with a bump allocator. To create a VNode, you can use either of:
@@ -113,6 +117,9 @@ pub enum VNode<'src> {
///
///
Template(&'src VTemplate<'src>),
///
Placeholder(&'src VPlaceholder),
}
/// An Element's unique identifier.
@@ -131,8 +138,9 @@ impl<'src> VNode<'src> {
VNode::Element(el) => el.key,
VNode::Component(c) => c.key,
VNode::Fragment(f) => f.key,
VNode::Text(_t) => None,
VNode::Template(t) => t.key,
VNode::Text(_t) => None,
VNode::Placeholder(_p) => None,
}
}
@@ -153,6 +161,7 @@ impl<'src> VNode<'src> {
VNode::Fragment(_) => None,
VNode::Component(_) => None,
VNode::Template(_) => None,
VNode::Placeholder(el) => el.id.get(),
}
}
@@ -164,6 +173,7 @@ impl<'src> VNode<'src> {
VNode::Component(c) => VNode::Component(c),
VNode::Fragment(f) => VNode::Fragment(f),
VNode::Template(t) => VNode::Template(t),
VNode::Placeholder(p) => VNode::Placeholder(p),
}
}
}
@@ -199,6 +209,10 @@ impl Debug for VNode<'_> {
.debug_struct("VNode::Templates")
.field("template_id", &temp.template.id)
.finish(),
VNode::Placeholder(place) => s
.debug_struct("VNode::Placeholder")
.field("id", &place.id)
.finish(),
}
}
}