pub enum VNode {
Element(VElement),
Text(String),
Fragment(Vec<VNode>),
Dynamic(Rc<RefCell<Box<dyn Fn() -> VNode>>>, Rc<RefCell<Option<Node>>>),
Empty,
}Expand description
A virtual DOM node.
Variants§
Element(VElement)
An HTML element with tag, attributes, event listeners, and children.
Text(String)
A text node.
Fragment(Vec<VNode>)
A fragment containing multiple nodes.
Dynamic(Rc<RefCell<Box<dyn Fn() -> VNode>>>, Rc<RefCell<Option<Node>>>)
A dynamic node that re-renders when signals change.
Empty
A placeholder for empty/false conditions.
Implementations§
Source§impl VNode
impl VNode
Sourcepub fn element(tag: &str) -> VElementBuilder
pub fn element(tag: &str) -> VElementBuilder
Create an element node.
Sourcepub fn same_type(&self, other: &VNode) -> bool
pub fn same_type(&self, other: &VNode) -> bool
Quick check: can we patch self (old) into other (new) in-place?
Two nodes can be patched if they have the same VNodeType (same variant,
same tag for elements).
Sourcepub fn key(&self) -> Option<&str>
pub fn key(&self) -> Option<&str>
Return the rendering key (:key attribute) for this node, if any.
Only elements may have keys.
Sourcepub fn dom_node(&self) -> Option<Node>
pub fn dom_node(&self) -> Option<Node>
Return a reference to the actual DOM node if this VNode has been mounted/rendered.
Sourcepub fn set_dom_node(&self, node: Node)
pub fn set_dom_node(&self, node: Node)
Set the DOM node reference on this VNode (called during mount/patch).
Sourcepub fn keyed_children(&self) -> Vec<(usize, &VNode)>
pub fn keyed_children(&self) -> Vec<(usize, &VNode)>
Recursively collect all (child_index, VNode) pairs that have a key.
Used by the keyed children reconciliation algorithm.