pub enum VirtualNode<T = ()> {
Element {
tag: Tag,
attributes: Vec<AttributeEntry>,
children: Vec<VirtualNode>,
key: Option<String>,
props: Option<Box<T>>,
},
Text(TextNode),
Fragment(Vec<VirtualNode>),
Dynamic(DynamicNode),
Empty,
}Expand description
Represents a node in the virtual DOM tree.
The core enum representing elements, text, fragments, and empty nodes.
The generic parameter T carries the component props type for component nodes.
For non-component nodes, T defaults to ().
Variants§
Element
An element node with a tag, attributes, children, and optional props.
Fields
attributes: Vec<AttributeEntry>The attributes attached to this element.
children: Vec<VirtualNode>The child nodes.
Text(TextNode)
A text node containing string content and an optional reactive signal.
Fragment(Vec<VirtualNode>)
A fragment of multiple nodes without a wrapper element.
Dynamic(DynamicNode)
A dynamic node that re-renders based on signal changes.
Empty
An empty placeholder node.
Implementations§
Source§impl<T> VirtualNode<T>
Implementation of virtual node construction and property extraction.
impl<T> VirtualNode<T>
Implementation of virtual node construction and property extraction.
Sourcepub fn try_get_tag_name(&self) -> Option<String>
pub fn try_get_tag_name(&self) -> Option<String>
Returns the tag name if this is an element or component node.
§Returns
Option<String>- The tag name, orNoneif not an element.
Sourcepub fn try_get_children(&self) -> Option<&Vec<VirtualNode>>
pub fn try_get_children(&self) -> Option<&Vec<VirtualNode>>
Returns a reference to the children of this node, if it has any.
Returns Some for Element and Fragment variants, None otherwise.
§Returns
Option<&Vec<VirtualNode>>- The children, orNone.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Sourcepub fn try_get_props(&self) -> Option<&T>
pub fn try_get_props(&self) -> Option<&T>
Returns a reference to the props of this node, if it has any.
Only Element variants with component tags carry props.
§Returns
Option<&T>- The props reference, orNone.
Sourcepub fn try_take_props(&mut self) -> Option<T>
pub fn try_take_props(&mut self) -> Option<T>
Takes the props out of this node, leaving None in its place.
§Returns
Option<T>- The props, orNoneif this node has no props.
Sourcepub fn take_children(&mut self) -> VirtualNode
pub fn take_children(&mut self) -> VirtualNode
Takes the children out of this node, replacing them with an empty vector.
Returns a VirtualNode (Fragment or single child) representation of the children.
§Returns
VirtualNode- The children as a virtual node.
Source§impl VirtualNode<()>
Implementation of virtual node construction for VirtualNode<()>.
impl VirtualNode<()>
Implementation of virtual node construction for VirtualNode<()>.
Sourcepub fn create_dynamic<F>(render_fn: F) -> Selfwhere
F: FnMut() -> Self + 'static,
pub fn create_dynamic<F>(render_fn: F) -> Selfwhere
F: FnMut() -> Self + 'static,
Constructs a Self::Dynamic from a render closure with hook context management.
§Arguments
FnMut() -> Self + 'static- The render closure that produces a virtual node tree. Called on initial render and on every signal update.
§Returns
Self- ASelf::Dynamicwrapping the render closure with a freshHookContext.
Sourcepub fn create_dynamic_with_context<F>(render_fn: F) -> Selfwhere
F: FnMut(&mut HookContext) -> Self + 'static,
pub fn create_dynamic_with_context<F>(render_fn: F) -> Selfwhere
F: FnMut(&mut HookContext) -> Self + 'static,
Constructs a Self::Dynamic for match expressions where arm hook
isolation is required. The render closure receives a &mut HookContext
so it can call set_arm_changed before each arm body.
§Arguments
FnMut(&mut HookContext) -> Self + 'static- The render closure that receives a mutable reference to the hook context.
§Returns
Self- ASelf::Dynamicwrapping the render closure with a freshHookContext.
Trait Implementations§
Source§impl<T: Clone> Clone for VirtualNode<T>
Clones a VirtualNode<T> by deep-copying all fields.
impl<T: Clone> Clone for VirtualNode<T>
Clones a VirtualNode<T> by deep-copying all fields.
Source§impl<T: Debug> Debug for VirtualNode<T>
Debug formatting for VirtualNode<T>.
impl<T: Debug> Debug for VirtualNode<T>
Debug formatting for VirtualNode<T>.
Skips Dynamic inner details and props for brevity.
Source§impl<T> Default for VirtualNode<T>
Default implementation returns VirtualNode::Empty.
impl<T> Default for VirtualNode<T>
Default implementation returns VirtualNode::Empty.
Source§impl IntoNode for VirtualNode
Converts a VirtualNode into itself via IntoNode.
impl IntoNode for VirtualNode
Converts a VirtualNode into itself via IntoNode.
Source§fn into_node(self) -> VirtualNode
fn into_node(self) -> VirtualNode
Source§impl<T: PartialEq> PartialEq for VirtualNode<T>
Visual equality comparison for virtual DOM nodes.
impl<T: PartialEq> PartialEq for VirtualNode<T>
Visual equality comparison for virtual DOM nodes.
Used by DynamicNode re-rendering to skip unnecessary DOM patches when the rendered output has not changed. Event attributes are always considered equal because re-binding event listeners is handled separately by the handler registry and does not affect visual output. Dynamic nodes manage their own subtree re-rendering, so two Dynamic variants are always considered equal — the inner renderer handles patching when the dynamic content actually changes.