Documentation
¶
Index ¶
- type Arena
- type Attribute
- type AttributeSet
- func (a *AttributeSet) Attr(name string) (string, bool)
- func (a *AttributeSet) AttrCount() int
- func (a *AttributeSet) AttrValue(name string) string
- func (a *AttributeSet) Attributes() iter.Seq2[string, string]
- func (a *AttributeSet) RemoveAttr(name string) bool
- func (a *AttributeSet) SetAttr(name, value string) bool
- func (a *AttributeSet) SetAttributes(attributes ...Attribute)
- func (a *AttributeSet) SortedAttributes() iter.Seq2[string, string]
- type Namespace
- type Node
- func (dst *Node) AdoptChildren(src *Node)
- func (n *Node) AppendChild(child *Node)
- func (n *Node) ClearChildren()
- func (n *Node) CopyAttributes(source *Node)
- func (n *Node) EqualAttributes(other *Node) bool
- func (n *Node) InsertBefore(child, before *Node)
- func (n *Node) KeepChildren(keep func(*Node) bool)
- func (n *Node) LastChild() *Node
- func (n *Node) PreviousSibling() *Node
- func (n *Node) RemoveChild(child *Node) bool
- func (n *Node) ShareAttributes(source *Node)
- func (n *Node) String() string
- func (n *Node) Within(root *Node) bool
- type NodeType
- type StateSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Arena ¶
type Arena struct {
// contains filtered or unexported fields
}
Arena allocates stable nodes in blocks. A producer can discard the arena after building its tree, or reuse it once all published nodes are retired. Reset invalidates all previous node pointers.
func (*Arena) CloneCompact ¶
CloneCompact copies the live subtree into a new string backing store. Identical strings share storage, and the result can outlive the input tree.
type Attribute ¶
type Attribute struct{ Name, Value string }
Attribute is an authored name/value pair. Names retain their exact spelling; the HTML parser applies ASCII folding and foreign-content adjustments.
type AttributeSet ¶
type AttributeSet struct {
// contains filtered or unexported fields
}
AttributeSet stores a compact collection of attributes. Empty sets need only a nil pointer. Small elements use a compact sorted list; larger sets use a map without duplicating names in a second index.
func (*AttributeSet) AttrCount ¶
func (a *AttributeSet) AttrCount() int
func (*AttributeSet) AttrValue ¶
func (a *AttributeSet) AttrValue(name string) string
AttrValue returns an attribute's value, or an empty string if absent.
func (*AttributeSet) Attributes ¶
func (a *AttributeSet) Attributes() iter.Seq2[string, string]
Attributes visits attributes without allocating. Order is unspecified. Removing or updating the currently yielded attribute is allowed; other mutations during iteration are not supported. Pairs are values, never writable storage views.
func (*AttributeSet) RemoveAttr ¶
func (a *AttributeSet) RemoveAttr(name string) bool
RemoveAttr removes an attribute, returning whether it was present.
func (*AttributeSet) SetAttr ¶
func (a *AttributeSet) SetAttr(name, value string) bool
SetAttr changes an attribute, returning whether its value changed.
func (*AttributeSet) SetAttributes ¶
func (a *AttributeSet) SetAttributes(attributes ...Attribute)
SetAttributes replaces all attributes with an owned copy and reuses capacity. Duplicate names keep their first value, matching HTML tokenization.
func (*AttributeSet) SortedAttributes ¶
func (a *AttributeSet) SortedAttributes() iter.Seq2[string, string]
SortedAttributes visits attributes in name order. Small lists need no extra storage. Large maps allocate a sorted name buffer for deterministic output. Do not change attributes during iteration.
type Node ¶
type Node struct {
AttributeSet
Parent *Node
Data string
Children []*Node
Order uint32
States StateSet[uint16]
Type NodeType
Namespace Namespace
}
Node is the ordered logical node shared by native UI content producers. Its address stays stable while attached, detached, or moved to another parent.
func NewDocument ¶
func NewDocument() *Node
func NewElement ¶
func (*Node) AdoptChildren ¶
AdoptChildren moves all of src's children to dst in their existing order.
func (*Node) AppendChild ¶
func (*Node) ClearChildren ¶
func (n *Node) ClearChildren()
ClearChildren detaches all direct children while retaining list capacity.
func (*Node) CopyAttributes ¶
CopyAttributes copies into independently writable storage.
func (*Node) EqualAttributes ¶
EqualAttributes compares authored attributes without exposing their storage.
func (*Node) InsertBefore ¶
InsertBefore inserts a detached child before a sibling. A nil sibling appends.
func (*Node) KeepChildren ¶
KeepChildren removes children rejected by keep, preserving relative order.
func (*Node) PreviousSibling ¶
func (*Node) RemoveChild ¶
RemoveChild detaches a child and reports whether it belonged to n.
func (*Node) ShareAttributes ¶
ShareAttributes shares source's storage without copying it. Subsequent edits to either node detach its attributes. A nil source clears the attributes. Sharing does not extend the lifetime of parser-owned names or values. Independent destinations may share a read-only source concurrently.