Skip to main content

VirtualNode

Enum VirtualNode 

Source
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

§tag: Tag

The tag type of this element.

§attributes: Vec<AttributeEntry>

The attributes attached to this element.

§children: Vec<VirtualNode>

The child nodes.

§key: Option<String>

An optional key for diffing.

§

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.

Source

pub fn get_element_node(tag_name: &str) -> Self

Creates a new element node with the given tag name.

Source

pub fn get_text_node(content: &str) -> Self

Creates a new text node with the given content.

Source

pub fn with_attribute(self, name: &str, value: AttributeValue) -> Self

Adds an attribute to this node if it is an element.

Source

pub fn with_child(self, child: VirtualNode) -> Self

Adds a child node to this node if it is an element.

Source

pub fn is_component(&self) -> bool

Returns true if this node is a component node.

Source

pub fn tag_name(&self) -> Option<String>

Returns the tag name if this is an element or component node.

Source

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.

Source

pub fn get_children(&self) -> Vec<VirtualNode>

Extracts children from this node if it is an element.

Source

pub fn try_get_text(&self) -> Option<String>

Extracts text content from this node.

Source

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.

Source

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.

Source§

fn as_node(&self) -> Option<VirtualNode>

Converts this value into a VirtualNode, if possible.
Source§

impl AsNode for VirtualNode

Converts a VirtualNode reference into an owned node.

Source§

fn as_node(&self) -> Option<VirtualNode>

Converts this value into a VirtualNode, if possible.
Source§

impl Clone for VirtualNode

Source§

fn clone(&self) -> VirtualNode

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for VirtualNode

Source§

fn default() -> VirtualNode

Returns the “default value” for a type. Read more
Source§

impl IntoNode for VirtualNode

Converts a VirtualNode into itself via IntoNode.

Source§

fn into_node(self) -> VirtualNode

Converts this value into a VirtualNode by consuming it.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more