kelo

Форк
0
/
node.go 
101 строка · 2.2 Кб
1
package godom
2

3
import "gitverse.ru/metalcore/kelo/wrapper"
4

5
type NodeValuer interface {
6
	EventTargetValuer
7

8
	BaseURI() string
9
	FirstChild() NodeValuer
10
	IsConnected() bool
11
	LastChild() NodeValuer
12
	NextSibling() NodeValuer
13
	NodeName() string
14
	NodeType() NodeType
15
	NodeValue() string
16
	SetNodeValue(string) NodeValuer
17

18
	AppendChild(NodeValuer) NodeValuer
19
	CloneNode(bool) NodeValuer
20
	Contains(NodeValuer) bool
21
	GetRootNode() NodeValuer
22
	HasChildNodes() bool
23
	RemoveChild(NodeValuer) NodeValuer
24
	ReplaceChild(NodeValuer, NodeValuer) NodeValuer
25
}
26

27
type Node struct {
28
	EventTarget
29
}
30

31
func NewNode(v wrapper.JSValuer) *Node {
32
	return &Node{*NewEventTarget(v)}
33
}
34

35
func (n *Node) BaseURI() string {
36
	return n.GetJS().Get("baseURI").String()
37
}
38

39
func (n *Node) FirstChild() NodeValuer {
40
	return NewNode(n.GetJS().Get("firstChild"))
41
}
42

43
func (n *Node) IsConnected() bool {
44
	return n.GetJS().Get("isConnected").Bool()
45
}
46

47
func (n *Node) LastChild() NodeValuer {
48
	return NewNode(n.GetJS().Get("lastChild"))
49
}
50

51
func (n *Node) NextSibling() NodeValuer {
52
	return NewNode(n.GetJS().Get("nextSibling"))
53
}
54

55
func (n *Node) NodeName() string {
56
	return n.GetJS().Get("nodeName").String()
57
}
58

59
func (n *Node) NodeType() NodeType {
60
	return NodeType(n.GetJS().Get("nodeType").Int())
61
}
62

63
func (n *Node) NodeValue() string {
64
	return n.GetJS().Get("nodeValue").String()
65
}
66

67
func (n *Node) SetNodeValue(v string) NodeValuer {
68
	n.GetJS().Set("nodeValue", v)
69
	return n
70
}
71

72
func (n *Node) AppendChild(node NodeValuer) NodeValuer {
73
	n.GetJS().Call("appendChild", node.GetJS().Value())
74
	return n
75
}
76

77
func (n *Node) CloneNode(deep bool) NodeValuer {
78
	return NewNode(n.GetJS().Call("cloneNode", deep))
79
}
80

81
func (n *Node) Contains(node NodeValuer) bool {
82
	return n.GetJS().Call("contains", node.GetJS().Value()).Bool()
83
}
84

85
func (n *Node) GetRootNode() NodeValuer {
86
	return NewNode(n.GetJS().Call("getRootNode"))
87
}
88

89
func (n *Node) HasChildNodes() bool {
90
	return n.GetJS().Call("hasChildNodes").Bool()
91
}
92

93
func (n *Node) RemoveChild(node NodeValuer) NodeValuer {
94
	n.GetJS().Call("removeChild", node.GetJS().Value())
95
	return n
96
}
97

98
func (n *Node) ReplaceChild(newChild, oldChild NodeValuer) NodeValuer {
99
	n.GetJS().Call("replaceChild", newChild.GetJS().Value(), oldChild.GetJS().Value())
100
	return n
101
}
102

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.