-
Notifications
You must be signed in to change notification settings - Fork 0
/
text.go
35 lines (29 loc) · 1.19 KB
/
text.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package dom
import (
"golang.org/x/net/html"
"github.com/crhntr/dom/spec"
)
type Text struct {
node *html.Node
}
func (t *Text) Data() string { return t.node.Data }
func (t *Text) SetData(d string) { t.node.Data = d }
func (t *Text) NodeType() spec.NodeType { return nodeType(t.node.Type) }
func (t *Text) IsConnected() bool { return isConnected(t.node) }
func (t *Text) OwnerDocument() spec.Document { return ownerDocument(t.node) }
func (t *Text) Length() int { return len(t.node.Data) }
func (t *Text) ParentNode() spec.Node { return parentNode(t.node) }
func (t *Text) ParentElement() spec.Element { return parentElement(t.node) }
func (t *Text) PreviousSibling() spec.ChildNode { return previousSibling(t.node) }
func (t *Text) NextSibling() spec.ChildNode { return nextSibling(t.node) }
func (t *Text) TextContent() string { return t.node.Data }
func (t *Text) CloneNode(_ bool) spec.Node {
return &Text{
node: &html.Node{
Type: html.TextNode,
Data: t.node.Data,
},
}
}
func (t *Text) IsSameNode(other spec.Node) bool { return isSameNode(t.node, other) }
func (t *Text) String() string { return t.node.Data }