euv_core/vdom/node/enum.rs
1use crate::*;
2
3/// Represents the type of an HTML tag or a component.
4///
5/// Distinguishes between standard HTML elements and user-defined components.
6#[derive(Clone, Debug, Eq, PartialEq)]
7pub enum Tag {
8 /// A standard HTML element identified by its tag name.
9 Element(String),
10 /// A custom component type.
11 Component(String),
12}
13
14/// Represents a node in the virtual DOM tree.
15///
16/// The core enum representing elements, text, fragments, and empty nodes.
17/// The generic parameter `T` carries the component props type for component nodes.
18/// For non-component nodes, `T` defaults to `()`.
19pub enum VirtualNode<T = ()> {
20 /// An element node with a tag, attributes, children, and optional props.
21 Element {
22 /// The tag type of this element.
23 tag: Tag,
24 /// The attributes attached to this element.
25 attributes: Vec<AttributeEntry>,
26 /// The child nodes.
27 children: Vec<VirtualNode>,
28 /// An optional key for diffing.
29 key: Option<String>,
30 /// The component props, present only for component nodes.
31 props: Option<Box<T>>,
32 },
33 /// A text node containing string content and an optional reactive signal.
34 Text(TextNode),
35 /// A fragment of multiple nodes without a wrapper element.
36 Fragment(Vec<VirtualNode>),
37 /// A dynamic node that re-renders based on signal changes.
38 Dynamic(DynamicNode),
39 /// An empty placeholder node.
40 Empty,
41}