-
Notifications
You must be signed in to change notification settings - Fork 6
/
htmloptionscollection.go
executable file
·71 lines (53 loc) · 1.46 KB
/
htmloptionscollection.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package htmloptionscollection
import (
"sync"
"syscall/js"
"github.com/realPy/hogosuru/baseobject"
"github.com/realPy/hogosuru/htmlcollection"
)
var singleton sync.Once
var htmloptionscollectioninterface js.Value
//HTMLOptionsCollection struct
type HtmlOptionsCollection struct {
htmlcollection.HtmlCollection
}
type HtmlOptionsCollectionFrom interface {
HtmlOptionsCollection_() HtmlOptionsCollection
}
func (h HtmlOptionsCollection) HTMLOptionsCollection_() HtmlOptionsCollection {
return h
}
//GetInterface get the JS interface of formdata
func GetInterface() js.Value {
singleton.Do(func() {
var err error
if htmloptionscollectioninterface, err = baseobject.Get(js.Global(), "HTMLOptionsCollection"); err != nil {
htmloptionscollectioninterface = js.Undefined()
}
baseobject.Register(htmloptionscollectioninterface, func(v js.Value) (interface{}, error) {
return NewFromJSObject(v)
})
})
return htmloptionscollectioninterface
}
func NewFromJSObject(obj js.Value) (HtmlOptionsCollection, error) {
var h HtmlOptionsCollection
var err error
if fli := GetInterface(); !fli.IsUndefined() {
if obj.IsUndefined() || obj.IsNull() {
err = baseobject.ErrUndefinedValue
} else {
if obj.InstanceOf(fli) {
h.BaseObject = h.SetObject(obj)
} else {
err = ErrNotAnHTMLOptionsCollection
}
}
} else {
err = ErrNotImplemented
}
return h, err
}
func (h HtmlOptionsCollection) Length() (int, error) {
return h.GetAttributeInt("length")
}