pub enum Tag {
Element(Cow<'static, str>),
Component(Cow<'static, str>),
Portal(Cow<'static, str>),
}Expand description
Represents the type of an HTML tag or a component.
Distinguishes between standard HTML elements and user-defined components.
OPT 2: tag names are Cow<'static, str>. The html! macro emits
Cow::Borrowed("div") for the common static case so a single
static-string slice is reused across every rendered tree without
per-element heap allocation. Runtime-derived tags (rare — only
used by Tag::Portal whose target: is a user expression) fall
back to Cow::Owned(String::from(expr)).
Variants§
Element(Cow<'static, str>)
A standard HTML element identified by its tag name.
Component(Cow<'static, str>)
A custom component type.
Portal(Cow<'static, str>)
A portal placeholder whose children are rendered into a different DOM subtree than the rest of the virtual DOM.
The payload is a CSS selector ("#modal-root",
"body", ".toast-host") identifying the destination
element. The renderer resolves the selector at mount time
via document.query_selector(...), falling back to
document.body() when the selector matches nothing.
Portal nodes render an HTML comment marker in their declared position so the parent’s DOM tree stays structurally intact (the alternative — leaving a hole in the parent — breaks euv’s positional patch loop, which walks child nodes by index).
Patch semantics:
- When the target selector is unchanged between renders, the portal’s children are patched in place inside the target element.
- When the target selector changes, the previous target’s children are unmounted and the new target receives a fresh mount.
Designed for modals, tooltips, dropdowns, and, toasts —
UI that needs to escape overflow: hidden parents and
sit at the document root regardless of where it was
declared in the virtual DOM.