Skip to content

enum

VNode

pub enum VNode {
    Element(VElement),
    Text(String),
}

A node in the rendered tree: an element, or text.

Variants

Element

Element(VElement)

An element.

Text

Text(String)

Text.

Methods

text

pub fn text(s: impl Into<String>) -> VNode

A text node.

element

pub fn element(tag: &str) -> VNode

An element with tag, and no attributes, handlers or children yet.

attr

pub fn attr(self, name: &str, value: impl Into<Value>) -> VNode

Builder: set an attribute (no-op on text nodes).

on

pub fn on(self, event: &str, handler: Handler) -> VNode

Builder: add an event handler (no-op on text nodes).

child

pub fn child(self, node: VNode) -> VNode

Builder: append a child (no-op on text nodes).

as_element

pub fn as_element(&self) -> Option<&VElement>

The element, if it's one.

text_content

pub fn text_content(&self) -> String

Concatenated text of this node and its descendants.

find

pub fn find(&self, path: &[usize]) -> Option<&VNode>

Descend by child indices.

find_mut

pub fn find_mut(&mut self, path: &[usize]) -> Option<&mut VNode>

The node at path below this one (empty: this node), to change it.

Trait implementations