Documentation
¶
Overview ¶
Package dom defines Growse's browser-owned document model.
Index ¶
- type Document
- func (d *Document) AppendChild(parent, child *Node) error
- func (d *Document) CreateElement(tagName string, attributes map[string]string) *Node
- func (d *Document) CreateText(text string) *Node
- func (d *Document) ElementCount() int
- func (d *Document) GetElementByID(id string) (*Node, bool)
- func (d *Document) IsConnected(node *Node) bool
- func (d *Document) NodeByID(id NodeID) (*Node, bool)
- func (d *Document) NodeCount() int
- func (d *Document) QuerySelector(value string) (*Node, bool)
- func (d *Document) Remove(id NodeID) ([]NodeID, bool)
- func (d *Document) RemoveAttribute(id NodeID, name string) bool
- func (d *Document) SetAttribute(id NodeID, name, value string) bool
- func (d *Document) SetTextContent(id NodeID, value string) bool
- func (d *Document) Title() string
- type Node
- type NodeID
- type NodeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
Root *Node
// contains filtered or unexported fields
}
Document owns a DOM tree and its node indexes.
func NewDocument ¶
func NewDocument() *Document
NewDocument creates an empty document with a document root node.
func (*Document) AppendChild ¶
AppendChild attaches child beneath parent.
func (*Document) CreateElement ¶
CreateElement creates an unattached element owned by the document.
func (*Document) CreateText ¶
CreateText creates an unattached text node owned by the document.
func (*Document) ElementCount ¶
ElementCount returns the number of element nodes.
func (*Document) GetElementByID ¶
GetElementByID returns the first element with the given id attribute.
func (*Document) IsConnected ¶
IsConnected はノードがDocumentのルートツリーに接続されているかを返す。
func (*Document) QuerySelector ¶
QuerySelector は対応する単純セレクターに最初に一致する要素を返す。
func (*Document) RemoveAttribute ¶ added in v0.8.0
RemoveAttribute removes an element attribute and reports whether it existed.
func (*Document) SetAttribute ¶
SetAttribute は要素の属性を設定し、値が変化した場合にtrueを返す。
func (*Document) SetTextContent ¶
SetTextContent は指定したノードの子を1つのテキストノードへ置き換える。
type Node ¶
type Node struct {
ID NodeID
Type NodeType
TagName string
Text string
Attributes map[string]string
// ControlValue and ControlChecked hold browser-owned live form state. The
// corresponding HTML attributes remain the reset defaults.
ControlValue string
ControlValueDirty bool
ControlChecked bool
ControlCheckedDirty bool
Parent *Node
Children []*Node
// contains filtered or unexported fields
}
Node is one item in a Growse DOM tree.
func (*Node) TextContent ¶
TextContent returns the concatenated text of the node and its descendants.