kelo
/
node.go
101 строка · 2.2 Кб
1package godom
2
3import "gitverse.ru/metalcore/kelo/wrapper"
4
5type NodeValuer interface {
6EventTargetValuer
7
8BaseURI() string
9FirstChild() NodeValuer
10IsConnected() bool
11LastChild() NodeValuer
12NextSibling() NodeValuer
13NodeName() string
14NodeType() NodeType
15NodeValue() string
16SetNodeValue(string) NodeValuer
17
18AppendChild(NodeValuer) NodeValuer
19CloneNode(bool) NodeValuer
20Contains(NodeValuer) bool
21GetRootNode() NodeValuer
22HasChildNodes() bool
23RemoveChild(NodeValuer) NodeValuer
24ReplaceChild(NodeValuer, NodeValuer) NodeValuer
25}
26
27type Node struct {
28EventTarget
29}
30
31func NewNode(v wrapper.JSValuer) *Node {
32return &Node{*NewEventTarget(v)}
33}
34
35func (n *Node) BaseURI() string {
36return n.GetJS().Get("baseURI").String()
37}
38
39func (n *Node) FirstChild() NodeValuer {
40return NewNode(n.GetJS().Get("firstChild"))
41}
42
43func (n *Node) IsConnected() bool {
44return n.GetJS().Get("isConnected").Bool()
45}
46
47func (n *Node) LastChild() NodeValuer {
48return NewNode(n.GetJS().Get("lastChild"))
49}
50
51func (n *Node) NextSibling() NodeValuer {
52return NewNode(n.GetJS().Get("nextSibling"))
53}
54
55func (n *Node) NodeName() string {
56return n.GetJS().Get("nodeName").String()
57}
58
59func (n *Node) NodeType() NodeType {
60return NodeType(n.GetJS().Get("nodeType").Int())
61}
62
63func (n *Node) NodeValue() string {
64return n.GetJS().Get("nodeValue").String()
65}
66
67func (n *Node) SetNodeValue(v string) NodeValuer {
68n.GetJS().Set("nodeValue", v)
69return n
70}
71
72func (n *Node) AppendChild(node NodeValuer) NodeValuer {
73n.GetJS().Call("appendChild", node.GetJS().Value())
74return n
75}
76
77func (n *Node) CloneNode(deep bool) NodeValuer {
78return NewNode(n.GetJS().Call("cloneNode", deep))
79}
80
81func (n *Node) Contains(node NodeValuer) bool {
82return n.GetJS().Call("contains", node.GetJS().Value()).Bool()
83}
84
85func (n *Node) GetRootNode() NodeValuer {
86return NewNode(n.GetJS().Call("getRootNode"))
87}
88
89func (n *Node) HasChildNodes() bool {
90return n.GetJS().Call("hasChildNodes").Bool()
91}
92
93func (n *Node) RemoveChild(node NodeValuer) NodeValuer {
94n.GetJS().Call("removeChild", node.GetJS().Value())
95return n
96}
97
98func (n *Node) ReplaceChild(newChild, oldChild NodeValuer) NodeValuer {
99n.GetJS().Call("replaceChild", newChild.GetJS().Value(), oldChild.GetJS().Value())
100return n
101}
102