VNode reference
Purpose
VNode is the normalized Node representation shared by deterministic
HTML rendering and unit inspection.
Inputs
| Field | Required | Type | Behavior |
|---|---|---|---|
kind |
yes | element, text, or fragment | Selects the v0.1.1 node representation. |
tag |
for element | HTML tag | Required for element nodes. |
text |
for text | string | Escaped before rendering. |
attrs |
no | props map | Attribute handling follows Props. Event-handler attributes such as onclick, and URL-bearing attributes such as href, src, formaction, and poster fail validation. |
children |
no | Node list | Rendered in order. |
Boundary
Server HTML and tests consume the same tree. Prefer Text nodes for
user/provider content. v0.1.1 has no raw node kind.
Kind-specific validation is strict. Element nodes require tag
and may use attrs and children; Text nodes require text and
reject tag, attrs, and children; Fragment nodes use
children but reject tag, text, and attrs. Fields outside the selected
kind fail validation instead of being ignored.
Go Shape
import "github.com/busdk/bus-gx/pkg/gx"
node := gx.VNode{
Kind: "element",
Tag: "article",
Children: []gx.VNode{
{Kind: "text", Text: "Evidence note"},
},
}
The rendered output is:
<article>Evidence note</article>