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.
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 needs_patch(old: &VirtualNode, new: &VirtualNode) -> bool
pub fn needs_patch(old: &VirtualNode, new: &VirtualNode) -> bool
Determines whether the DOM needs to be patched when transitioning
from old to new.
Unlike PartialEq, this method treats two Dynamic variants as
different so that the renderer always re-evaluates dynamic
subtrees. This is essential for route-based match expressions
where different pages may occupy the same DynamicNode slot.
§Arguments
&VirtualNode- The old virtual node.&VirtualNode- The new virtual node.
§Returns
bool-trueif the DOM needs to be patched.
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 node.
Sourcepub fn try_get_prop(&self, name: &Attribute) -> Option<String>
pub fn try_get_prop(&self, name: &Attribute) -> Option<String>
Sourcepub fn try_get_signal_prop(&self, name: &Attribute) -> Option<Signal<String>>
pub fn try_get_signal_prop(&self, name: &Attribute) -> Option<Signal<String>>
Extracts a signal property from this node if it is an element with the named attribute.
Returns the raw Signal<String> so components can reactively read the current value
and subscribe to future changes, rather than receiving a snapshot string.
§Arguments
&Attribute- The attribute to look up.
§Returns
Option<Signal<String>>- The signal if found, orNone.
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 not a text node.
Sourcepub fn try_get_event(
&self,
name: &NativeEventName,
) -> Option<NativeEventHandler>
pub fn try_get_event( &self, name: &NativeEventName, ) -> 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 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.