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 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) -> Vec<VirtualNode>
pub fn get_children(&self) -> Vec<VirtualNode>
Extracts children from this node if it is an element.
§Returns
Vec<VirtualNode>: The children, or an empty vec 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>
Sourcepub fn try_get_callback(&self, name: &str) -> Option<NativeEventHandler>
pub fn try_get_callback(&self, name: &str) -> Option<NativeEventHandler>
Trait Implementations§
Source§impl AsNode for &VirtualNode
Converts a VirtualNode reference into an owned node.
impl AsNode for &VirtualNode
Converts a VirtualNode reference into an owned node.
Source§impl AsNode for VirtualNode
Converts a VirtualNode reference into an owned node.
impl AsNode for VirtualNode
Converts a VirtualNode reference into an owned node.
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.