Documentation
¶
Index ¶
- Variables
- func AssignDocumentOrder(root *Node)
- func DefaultSelectedIndex(selectNode *Node) int
- func HasDirtySelectedOption(selectNode *Node) bool
- func HasInputType(node *Node, inputType string) bool
- func InitializeElementStates(root *Node)
- func IsChecked(node *Node) bool
- func IsContentEditable(node *Node) bool
- func IsDisabled(node *Node) bool
- func IsEditingHost(node *Node) bool
- func IsPlaceholderShown(node *Node) bool
- func ResetForm(form *Node) bool
- func SameRadioGroup(left, right *Node) bool
- func SelectedIndex(selectNode *Node) int
- func SetLiveValue(node *Node, value string, dirty bool)
- func SetOptionSelected(option *Node, selected bool) bool
- func SetOptionSelectedAt(selectNode *Node, optionIndex int, selected bool) bool
- func SetSelectedIndex(selectNode *Node, selected int)
- func SetSelectedRange(selectNode *Node, start, end int) bool
- func SupportsDisabled(node *Node) bool
- func SupportsPlaceholder(node *Node) bool
- func SynchronizeCheckedAttribute(node *Node, present bool)
- func SynchronizePlaceholderAttribute(node *Node)
- func SynchronizeSelectAttribute(selectNode *Node, name string)
- func SynchronizeSelectChildren(node *Node)
- func SynchronizeSelectedAttribute(option *Node, present bool)
- func SynchronizeTextContent(node *Node)
- func SynchronizeValueAttribute(node *Node)
- func TabIndex(node *Node) (int, bool)
- type ElementState
- type Node
- type NodeType
- type Parser
- type StateSet
- type Token
- type TokenType
- type Tokenizer
Constants ¶
This section is empty.
Variables ¶
var ErrNestingDepth = errors.New("dom: maximum element depth (512) exceeded")
ErrNestingDepth reports HTML nesting beyond the parser's 512-element limit.
Functions ¶
func AssignDocumentOrder ¶
func AssignDocumentOrder(root *Node)
AssignDocumentOrder records preorder positions without allocating.
func DefaultSelectedIndex ¶
DefaultSelectedIndex returns the effective selection produced by resetting the select from its authored option attributes.
func HasDirtySelectedOption ¶
func HasInputType ¶
func InitializeElementStates ¶
func InitializeElementStates(root *Node)
func IsContentEditable ¶
IsContentEditable resolves the enumerated contenteditable attribute through the element's ancestors.
func IsDisabled ¶
func IsEditingHost ¶
IsEditingHost reports whether node starts a contenteditable region. Nested editable descendants are not independent sequential focus targets.
func IsPlaceholderShown ¶
func ResetForm ¶
ResetForm restores controls owned by form to their authored defaults. The traversal includes controls associated through an explicit form attribute.
func SameRadioGroup ¶
func SelectedIndex ¶
SelectedIndex returns the first live selected option in tree order.
func SetLiveValue ¶
SetLiveValue updates the compact value state used by :placeholder-shown. The string itself remains owned by the generated form control.
func SetOptionSelected ¶
SetOptionSelected updates one option's selectedness as the selected IDL property does. A single-select keeps at most one selected option.
func SetOptionSelectedAt ¶
func SetSelectedIndex ¶
SetSelectedIndex updates live option selectedness. The selected option gets a dirty flag; options deselected as a consequence retain their dirtyness.
func SetSelectedRange ¶
SetSelectedRange applies a user range selection to a multiple select in one mutation pass. Disabled options retain their selectedness because keyboard and pointer input cannot toggle them.
func SupportsDisabled ¶
func SupportsPlaceholder ¶
func SynchronizeCheckedAttribute ¶
SynchronizeCheckedAttribute applies a checked content-attribute mutation to live checkedness while the control's dirty checkedness flag is clear.
func SynchronizePlaceholderAttribute ¶
func SynchronizePlaceholderAttribute(node *Node)
func SynchronizeSelectAttribute ¶
SynchronizeSelectAttribute applies multiple/size mutations to live selectedness using the select element's normalization rules.
func SynchronizeSelectChildren ¶
func SynchronizeSelectChildren(node *Node)
SynchronizeSelectChildren normalizes live selection after an option list changes. Keep the last selected option without resetting defaults or dirtyness.
func SynchronizeSelectedAttribute ¶
SynchronizeSelectedAttribute applies an option selected content-attribute mutation unless that option's live selectedness is dirty.
func SynchronizeTextContent ¶
func SynchronizeTextContent(node *Node)
SynchronizeTextContent updates a textarea's live value state from its child text while the dirty value flag is clear.
func SynchronizeValueAttribute ¶
func SynchronizeValueAttribute(node *Node)
SynchronizeValueAttribute updates live value state from an input value content attribute while the dirty value flag is clear.
Types ¶
type ElementState ¶
type ElementState uint16
const ( StateChecked ElementState = 1 << iota StatePlaceholderShown StateIndeterminate StateDirtyChecked StateValueEmpty StateDirtyValue StateDirtySelected )
type Node ¶
type Node struct {
Attributes map[string]string
Parent *Node
Data string
Children []*Node
Type NodeType
Order uint32
States StateSet[ElementState]
// contains filtered or unexported fields
}
func FormOwner ¶
FormOwner returns the form associated with a form control. An explicit form attribute takes precedence over the nearest ancestor form.
func NewDocument ¶
func NewDocument() *Node
func Parse ¶
Parse returns an independently owned DOM. Use a retained Parser when the previous DOM can be discarded to avoid allocations after warming its storage. Malformed HTML is repaired using the HTML tree construction rules. As before, sources without a leading doctype/html/head/body are parsed as body fragments.
func (*Node) AppendChild ¶
func (*Node) InsertBefore ¶
func (*Node) RemoveChild ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser builds DOM nodes directly from UTF-8 source. Its zero value is ready to use. Nodes, attributes, child slices and decoded text are reused on the next Parse or Reset call, which invalidates the previous result. A Parser must not be copied after use or used concurrently.
Unchanged text and names borrow the source string. Decoded strings borrow parser storage; they are immutable until the next Parse or Reset call.
type StateSet ¶
type StateSet[T ~uint16] struct { // contains filtered or unexported fields }
StateSet stores explicitly resolved boolean states in two compact bitsets. A valid bit distinguishes a live false value from an uninitialized state.
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
Tokenizer scans UTF-8 HTML, borrowing unchanged source text. It skips comments and declarations, recovers malformed input, and handles raw text elements. Returned tokens remain valid for the lifetime of the tokenizer.