-
Notifications
You must be signed in to change notification settings - Fork 23
/
extra.go
29 lines (24 loc) · 886 Bytes
/
extra.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
package godom
// This file implements useful functions not in DOM API
func (o *Object) RemoveAllChildNodes() {
for o.HasChildNodes() {
o.RemoveChild(o.LastChild())
}
}
// element.AppendBefore(newElement) - insert newElement before element.
// Some people call this as *insert before*, but this calling is confusing
// because the meaning of insertBefore() in DOM API is different.
// http://stackoverflow.com/a/32135318
func (o *Object) AppendBefore(n *Object) {
o.ParentNode().InsertBefore(n, o)
}
// element.AppendAfter(newElement) - insert newElement after element.
// Some people call this as *insert after*.
// http://stackoverflow.com/a/32135318
func (o *Object) AppendAfter(n *Object) {
o.ParentNode().InsertBefore(n, o.NextSibling())
}
// Check if the element is currently focused
func (o *Object) IsFocused() bool {
return o.IsEqualNode(Document.ActiveElement())
}