dom

package module
v0.1.0-alpha.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 8 Imported by: 0

README

dom Go Reference

This package has pure Go implementation of some Document Object Model functions using golang.org/x/net/html.Node.

It makes use of the awesome package andybalholm/cascadia.

The spec pacakge specifies interfaces; dom has implementations.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNode

func NewNode(node *html.Node) spec.Node

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

func (*Document) CloneNode

func (d *Document) CloneNode(deep bool) spec.Node

func (*Document) Contains

func (d *Document) Contains(other spec.Node) bool

func (*Document) CreateElement

func (*Document) CreateElement(localName string) spec.Element

func (*Document) CreateElementIs

func (*Document) CreateElementIs(localName, is string) spec.Element

func (*Document) CreateTextNode

func (*Document) CreateTextNode(text string) spec.Text

func (*Document) GetElementsByClassName

func (d *Document) GetElementsByClassName(name string) spec.ElementCollection

func (*Document) GetElementsByTagName

func (d *Document) GetElementsByTagName(name string) spec.ElementCollection

func (*Document) IsSameNode

func (d *Document) IsSameNode(other spec.Node) bool

func (*Document) NodeType

func (d *Document) NodeType() spec.NodeType

func (*Document) QuerySelector

func (d *Document) QuerySelector(query string) spec.Element

func (*Document) QuerySelectorAll

func (d *Document) QuerySelectorAll(query string) spec.NodeList[spec.Element]

func (*Document) TextContent

func (d *Document) TextContent() string

TextContent returns an empty string. The spec says it should return null https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent

type DocumentFragment

type DocumentFragment struct {
	// contains filtered or unexported fields
}

func NewDocumentFragment

func NewDocumentFragment(nodes []*html.Node) *DocumentFragment

func (*DocumentFragment) Append

func (d *DocumentFragment) Append(nodes ...spec.ChildNode)

func (*DocumentFragment) ChildElementCount

func (d *DocumentFragment) ChildElementCount() int

func (*DocumentFragment) Children

func (d *DocumentFragment) Children() spec.ElementCollection

func (*DocumentFragment) CloneNode

func (d *DocumentFragment) CloneNode(deep bool) spec.Node

func (*DocumentFragment) FirstElementChild

func (d *DocumentFragment) FirstElementChild() spec.Element

func (*DocumentFragment) IsSameNode

func (d *DocumentFragment) IsSameNode(other spec.Node) bool

func (*DocumentFragment) LastElementChild

func (d *DocumentFragment) LastElementChild() spec.Element

func (*DocumentFragment) NodeType

func (d *DocumentFragment) NodeType() spec.NodeType

func (*DocumentFragment) Prepend

func (d *DocumentFragment) Prepend(nodes ...spec.ChildNode)

func (*DocumentFragment) QuerySelector

func (d *DocumentFragment) QuerySelector(query string) spec.Element

func (*DocumentFragment) QuerySelectorAll

func (d *DocumentFragment) QuerySelectorAll(query string) spec.NodeList[spec.Element]

func (*DocumentFragment) ReplaceChildren

func (d *DocumentFragment) ReplaceChildren(nodes ...spec.ChildNode)

func (*DocumentFragment) TextContent

func (d *DocumentFragment) TextContent() string

type Element

type Element struct {
	// contains filtered or unexported fields
}

func (*Element) Append

func (e *Element) Append(nodes ...spec.Node)

func (*Element) AppendChild

func (e *Element) AppendChild(node spec.ChildNode) spec.ChildNode

func (*Element) ChildElementCount

func (e *Element) ChildElementCount() int

func (*Element) ChildNodes

func (e *Element) ChildNodes() spec.NodeList[spec.Node]

func (*Element) Children

func (e *Element) Children() spec.ElementCollection

func (*Element) ClassName

func (e *Element) ClassName() string

func (*Element) CloneNode

func (e *Element) CloneNode(deep bool) spec.Node

func (*Element) Closest

func (e *Element) Closest(selector string) spec.Element

func (*Element) Contains

func (e *Element) Contains(other spec.Node) bool

func (*Element) FirstChild

func (e *Element) FirstChild() spec.ChildNode

func (*Element) FirstElementChild

func (e *Element) FirstElementChild() spec.Element

func (*Element) GetAttribute

func (e *Element) GetAttribute(name string) string

func (*Element) GetElementsByClassName

func (e *Element) GetElementsByClassName(name string) spec.ElementCollection

func (*Element) GetElementsByTagName

func (e *Element) GetElementsByTagName(name string) spec.ElementCollection

func (*Element) HasAttribute

func (e *Element) HasAttribute(name string) bool

func (*Element) HasChildNodes

func (e *Element) HasChildNodes() bool

func (*Element) ID

func (e *Element) ID() string

func (*Element) InnerHTML

func (e *Element) InnerHTML() string

func (*Element) InsertBefore

func (e *Element) InsertBefore(node, child spec.ChildNode) spec.ChildNode

func (*Element) IsConnected

func (e *Element) IsConnected() bool

func (*Element) IsSameNode

func (e *Element) IsSameNode(other spec.Node) bool

func (*Element) LastChild

func (e *Element) LastChild() spec.ChildNode

func (*Element) LastElementChild

func (e *Element) LastElementChild() spec.Element

func (*Element) Length

func (e *Element) Length() int

func (*Element) Matches

func (e *Element) Matches(selector string) bool

func (*Element) NextSibling

func (e *Element) NextSibling() spec.ChildNode

func (*Element) NodeType

func (e *Element) NodeType() spec.NodeType

func (*Element) OuterHTML

func (e *Element) OuterHTML() string

func (*Element) OwnerDocument

func (e *Element) OwnerDocument() spec.Document

func (*Element) ParentElement

func (e *Element) ParentElement() spec.Element

func (*Element) ParentNode

func (e *Element) ParentNode() spec.Node

func (*Element) Prepend

func (e *Element) Prepend(nodes ...spec.Node)

func (*Element) PreviousSibling

func (e *Element) PreviousSibling() spec.ChildNode

func (*Element) QuerySelector

func (e *Element) QuerySelector(query string) spec.Element

func (*Element) QuerySelectorAll

func (e *Element) QuerySelectorAll(query string) spec.NodeList[spec.Element]

func (*Element) RemoveAttribute

func (e *Element) RemoveAttribute(name string)

func (*Element) RemoveChild

func (e *Element) RemoveChild(node spec.ChildNode) spec.ChildNode

func (*Element) ReplaceChild

func (e *Element) ReplaceChild(node, child spec.ChildNode) spec.ChildNode

func (*Element) ReplaceChildren

func (e *Element) ReplaceChildren(nodes ...spec.Node)

func (*Element) SetAttribute

func (e *Element) SetAttribute(name, value string)

func (*Element) SetInnerHTML

func (e *Element) SetInnerHTML(s string)

func (*Element) SetOuterHTML

func (e *Element) SetOuterHTML(s string)

func (*Element) TagName

func (e *Element) TagName() string

func (*Element) TextContent

func (e *Element) TextContent() string

func (*Element) ToggleAttribute

func (e *Element) ToggleAttribute(name string) bool

type Text

type Text struct {
	// contains filtered or unexported fields
}

func (*Text) CloneNode

func (t *Text) CloneNode(_ bool) spec.Node

func (*Text) Data

func (t *Text) Data() string

func (*Text) IsConnected

func (t *Text) IsConnected() bool

func (*Text) IsSameNode

func (t *Text) IsSameNode(other spec.Node) bool

func (*Text) Length

func (t *Text) Length() int

func (*Text) NextSibling

func (t *Text) NextSibling() spec.ChildNode

func (*Text) NodeType

func (t *Text) NodeType() spec.NodeType

func (*Text) OwnerDocument

func (t *Text) OwnerDocument() spec.Document

func (*Text) ParentElement

func (t *Text) ParentElement() spec.Element

func (*Text) ParentNode

func (t *Text) ParentNode() spec.Node

func (*Text) PreviousSibling

func (t *Text) PreviousSibling() spec.ChildNode

func (*Text) SetData

func (t *Text) SetData(d string)

func (*Text) TextContent

func (t *Text) TextContent() string

Directories

Path Synopsis
internal
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL