pub enum VirtualNode {
Element {
tag: Tag,
attributes: Vec<AttributeEntry>,
children: Vec<VirtualNode>,
key: Option<String>,
},
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.
Variants§
Element
An element node with a tag, attributes, and children.
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 VirtualNode
Implementation of virtual node construction and property extraction.
impl VirtualNode
Implementation of virtual node construction and property extraction.
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.
Sourcepub fn get_element_node(tag_name: &str) -> Self
pub fn get_element_node(tag_name: &str) -> Self
Sourcepub fn get_text_node(content: &str) -> Self
pub fn get_text_node(content: &str) -> Self
Sourcepub fn with_attribute(self, name: &str, value: AttributeValue) -> Self
pub fn with_attribute(self, name: &str, value: AttributeValue) -> Self
Sourcepub fn with_child(self, child: VirtualNode) -> Self
pub fn with_child(self, child: VirtualNode) -> Self
Sourcepub fn is_component(&self) -> bool
pub fn is_component(&self) -> bool
Sourcepub fn tag_name(&self) -> Option<String>
pub fn 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_prop(&self, name: &str) -> Option<String>
pub fn try_get_prop(&self, name: &str) -> Option<String>
Sourcepub fn try_get_typed_prop<T>(&self, name: &str) -> Option<T>where
T: FromStr,
pub fn try_get_typed_prop<T>(&self, name: &str) -> Option<T>where
T: FromStr,
Sourcepub fn get_children(&self) -> &[Self]
pub fn get_children(&self) -> &[Self]
Returns a slice of the children if this node is an element.
§Returns
&[Self]- The children slice, or an empty slice if not an element.
Sourcepub fn try_get_text(&self) -> Option<String>
pub fn try_get_text(&self) -> Option<String>
Extracts text content from this node.
§Returns
Option<String>- The text content, orNoneif unavailable.
Sourcepub fn try_get_event(&self, name: &str) -> Option<NativeEventHandler>
pub fn try_get_event(&self, name: &str) -> Option<NativeEventHandler>
Trait Implementations§
Source§impl Clone for VirtualNode
impl Clone for VirtualNode
Source§fn clone(&self) -> VirtualNode
fn clone(&self) -> VirtualNode
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VirtualNode
impl Debug for VirtualNode
Source§impl Default for VirtualNode
impl Default for VirtualNode
Source§fn default() -> VirtualNode
fn default() -> VirtualNode
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 PartialEq for VirtualNode
Visual equality comparison for virtual DOM nodes.
impl PartialEq for VirtualNode
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.