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 get_element_node(tag_name: &str) -> Self
pub fn get_element_node(tag_name: &str) -> Self
Creates a new element node with the given tag name.
Sourcepub fn get_text_node(content: &str) -> Self
pub fn get_text_node(content: &str) -> Self
Creates a new text node with the given content.
Sourcepub fn with_attribute(self, name: &str, value: AttributeValue) -> Self
pub fn with_attribute(self, name: &str, value: AttributeValue) -> Self
Adds an attribute to this node if it is an element.
Sourcepub fn with_child(self, child: VirtualNode) -> Self
pub fn with_child(self, child: VirtualNode) -> Self
Adds a child node to this node if it is an element.
Sourcepub fn is_component(&self) -> bool
pub fn is_component(&self) -> bool
Returns true if this node is a component node.
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.
Sourcepub fn try_get_prop(&self, name: &Attribute) -> Option<String>
pub fn try_get_prop(&self, name: &Attribute) -> Option<String>
Extracts a string property from this node if it is an element with the named attribute.
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.
Sourcepub fn get_children(&self) -> Vec<VirtualNode>
pub fn get_children(&self) -> Vec<VirtualNode>
Extracts children from this node if it is an element.
Sourcepub fn try_get_text(&self) -> Option<String>
pub fn try_get_text(&self) -> Option<String>
Extracts text content from this node.
Sourcepub fn try_get_event(
&self,
name: &NativeEventName,
) -> Option<NativeEventHandler>
pub fn try_get_event( &self, name: &NativeEventName, ) -> Option<NativeEventHandler>
Extracts an event handler from this node if it is an element with the named event attribute.
Sourcepub fn try_get_callback(&self, name: &str) -> Option<NativeEventHandler>
pub fn try_get_callback(&self, name: &str) -> Option<NativeEventHandler>
Extracts an event handler from this node by a custom attribute name.
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§fn as_node(&self) -> Option<VirtualNode>
fn as_node(&self) -> Option<VirtualNode>
VirtualNode, if possible.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§fn as_node(&self) -> Option<VirtualNode>
fn as_node(&self) -> Option<VirtualNode>
VirtualNode, if possible.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
VirtualNode by consuming it.