| @ -1,9 +0,0 @@ | |||||
| GO_FILES = $(shell find generate/*.json | ack '/(?P<fname>.*?)\.' --output '$$+{fname}.go') | |||||
| all: | |||||
| go generate | |||||
| .PHONY: all | |||||
| clean: | |||||
| rm $(GO_FILES) | |||||
| .PHONY: clean | |||||
| @ -1,19 +0,0 @@ | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Callback struct { | |||||
| js.Callback | |||||
| } | |||||
| func (c *Callback) JSValue() js.Value { return c.Callback.Value } | |||||
| type EventCallbackFunction func(*Event) | |||||
| func NewEventCallback(c EventCallbackFunction) *Callback { | |||||
| return &Callback{ | |||||
| Callback: js.NewEventCallback(0, func(evt js.Value) { | |||||
| c(NewEvent(evt)) | |||||
| }), | |||||
| } | |||||
| } | |||||
| @ -1,37 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Console struct { | |||||
| Value | |||||
| } | |||||
| func NewConsole(v js.Value) *Console { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToConsole() | |||||
| } | |||||
| func (v Value) ToConsole() *Console { return &Console{Value: v} } | |||||
| func (c *Console) Log(v ...interface{}) Value { | |||||
| vVaridic := make([]interface{}, 0) | |||||
| for _, a := range v { | |||||
| vVaridic = append(vVaridic, ToJSValue(a)) | |||||
| } | |||||
| val := Value{Value: c.Call("log", vVaridic...)} | |||||
| return val | |||||
| } | |||||
| func (c *Console) Error(v ...interface{}) Value { | |||||
| vVaridic := make([]interface{}, 0) | |||||
| for _, a := range v { | |||||
| vVaridic = append(vVaridic, ToJSValue(a)) | |||||
| } | |||||
| val := Value{Value: c.Call("error", vVaridic...)} | |||||
| return val | |||||
| } | |||||
| func (c *Console) Dir(v JSValue) Value { | |||||
| val := Value{Value: c.Call("dir", ToJSValue(v))} | |||||
| return val | |||||
| } | |||||
| @ -1,20 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package console | |||||
| import "syscall/js" | |||||
| import dom "github.com/brettlangdon/go-dom/v1" | |||||
| var c *dom.Console | |||||
| func init() { | |||||
| c = dom.NewConsole(js.Global().Get("console")) | |||||
| } | |||||
| func Log(v ...interface{}) dom.Value { | |||||
| return c.Log(v...) | |||||
| } | |||||
| func Error(v ...interface{}) dom.Value { | |||||
| return c.Error(v...) | |||||
| } | |||||
| func Dir(v dom.JSValue) dom.Value { | |||||
| return c.Dir(v) | |||||
| } | |||||
| @ -1,31 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type CustomElementRegistry struct { | |||||
| Value | |||||
| } | |||||
| func NewCustomElementRegistry(v js.Value) *CustomElementRegistry { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToCustomElementRegistry() | |||||
| } | |||||
| func (v Value) ToCustomElementRegistry() *CustomElementRegistry { | |||||
| return &CustomElementRegistry{Value: v} | |||||
| } | |||||
| func (c *CustomElementRegistry) Define(name string, constructor interface{}) Value { | |||||
| val := Value{Value: c.Call("define", ToJSValue(name), ToJSValue(constructor))} | |||||
| return val | |||||
| } | |||||
| func (c *CustomElementRegistry) Get(name string) Value { | |||||
| val := Value{Value: c.Call("get", ToJSValue(name))} | |||||
| return val | |||||
| } | |||||
| func (c *CustomElementRegistry) WhenDefined(name string) *Promise { | |||||
| val := Value{Value: c.Call("whenDefined", ToJSValue(name))} | |||||
| return NewPromise(val.JSValue()) | |||||
| } | |||||
| @ -1,20 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package customelements | |||||
| import "syscall/js" | |||||
| import dom "github.com/brettlangdon/go-dom/v1" | |||||
| var c *dom.CustomElementRegistry | |||||
| func init() { | |||||
| c = dom.NewCustomElementRegistry(js.Global().Get("customElements")) | |||||
| } | |||||
| func Define(name string, constructor interface{}) dom.Value { | |||||
| return c.Define(name, constructor) | |||||
| } | |||||
| func Get(name string) dom.Value { | |||||
| return c.Get(name) | |||||
| } | |||||
| func WhenDefined(name string) *dom.Promise { | |||||
| return c.WhenDefined(name) | |||||
| } | |||||
| @ -1,122 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Document struct { | |||||
| Value | |||||
| } | |||||
| func NewDocument(v js.Value) *Document { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToDocument() | |||||
| } | |||||
| func (v Value) ToDocument() *Document { return &Document{Value: v} } | |||||
| func (d *Document) GetBody() *Element { | |||||
| val := Value{Value: d.Get("body")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) CreateElement(tagName string) *Element { | |||||
| val := Value{Value: d.Call("createElement", ToJSValue(tagName))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetElementById(id string) *Element { | |||||
| val := Value{Value: d.Call("getElementById", ToJSValue(id))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetElementsByName(name string) []*Element { | |||||
| val := Value{Value: d.Call("getElementsByName", ToJSValue(name))} | |||||
| elms := make([]*Element, 0) | |||||
| for i := 0; i < val.Length(); i += 1 { | |||||
| elms = append(elms, NewElement(val.Index(i))) | |||||
| } | |||||
| return elms | |||||
| } | |||||
| func (d *Document) Write(markup string) Value { | |||||
| val := Value{Value: d.Call("write", ToJSValue(markup))} | |||||
| return val | |||||
| } | |||||
| func (d *Document) AddEventListener(t string, listener *Callback) Value { | |||||
| val := Value{Value: d.Call("addEventListener", ToJSValue(t), ToJSValue(listener))} | |||||
| return val | |||||
| } | |||||
| func (d *Document) AppendChild(aChild *Element) *Element { | |||||
| val := Value{Value: d.Call("appendChild", ToJSValue(aChild))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetBaseURI() string { | |||||
| val := Value{Value: d.Get("baseURI")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) GetFirstChild() *Element { | |||||
| val := Value{Value: d.Get("firstChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetLastChild() *Element { | |||||
| val := Value{Value: d.Get("lastChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetNextSibling() *Element { | |||||
| val := Value{Value: d.Get("nextSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetPreviousSibling() *Element { | |||||
| val := Value{Value: d.Get("previousSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetParentElement() *Element { | |||||
| val := Value{Value: d.Get("parentElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetRootElement() *Element { | |||||
| val := Value{Value: d.Get("rootElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetPrefix() string { | |||||
| val := Value{Value: d.Get("prefix")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) GetNodeName() string { | |||||
| val := Value{Value: d.Get("nodeName")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) GetTextContent() string { | |||||
| val := Value{Value: d.Get("textContent")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) SetTextContent(v string) { | |||||
| d.Set("textContent", v) | |||||
| } | |||||
| func (d *Document) QuerySelector(selector string) *Element { | |||||
| val := Value{Value: d.Call("querySelector", ToJSValue(selector))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (d *Document) QuerySelectorAll(selector string) []*Element { | |||||
| val := Value{Value: d.Call("querySelectorAll", ToJSValue(selector))} | |||||
| elms := make([]*Element, 0) | |||||
| for i := 0; i < val.Length(); i += 1 { | |||||
| elms = append(elms, NewElement(val.Index(i))) | |||||
| } | |||||
| return elms | |||||
| } | |||||
| func (d *Document) AttachShadow(shadowRootInit ShadowRootInit) *ShadowRoot { | |||||
| val := Value{Value: d.Call("attachShadow", ToJSValue(shadowRootInit))} | |||||
| return NewShadowRoot(val.JSValue()) | |||||
| } | |||||
| func (d *Document) GetClassName() string { | |||||
| val := Value{Value: d.Get("className")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) SetClassName(v string) { | |||||
| d.Set("className", v) | |||||
| } | |||||
| func (d *Document) GetId() string { | |||||
| val := Value{Value: d.Get("id")} | |||||
| return val.String() | |||||
| } | |||||
| func (d *Document) SetId(v string) { | |||||
| d.Set("id", v) | |||||
| } | |||||
| @ -1,86 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package document | |||||
| import "syscall/js" | |||||
| import dom "github.com/brettlangdon/go-dom/v1" | |||||
| var d *dom.Document | |||||
| func init() { | |||||
| d = dom.NewDocument(js.Global().Get("document")) | |||||
| } | |||||
| func GetBody() *dom.Element { | |||||
| return d.GetBody() | |||||
| } | |||||
| func CreateElement(tagName string) *dom.Element { | |||||
| return d.CreateElement(tagName) | |||||
| } | |||||
| func GetElementById(id string) *dom.Element { | |||||
| return d.GetElementById(id) | |||||
| } | |||||
| func GetElementsByName(name string) []*dom.Element { | |||||
| return d.GetElementsByName(name) | |||||
| } | |||||
| func Write(markup string) dom.Value { | |||||
| return d.Write(markup) | |||||
| } | |||||
| func AddEventListener(t string, listener *dom.Callback) dom.Value { | |||||
| return d.AddEventListener(t, listener) | |||||
| } | |||||
| func AppendChild(aChild *dom.Element) *dom.Element { | |||||
| return d.AppendChild(aChild) | |||||
| } | |||||
| func GetBaseURI() string { | |||||
| return d.GetBaseURI() | |||||
| } | |||||
| func GetFirstChild() *dom.Element { | |||||
| return d.GetFirstChild() | |||||
| } | |||||
| func GetLastChild() *dom.Element { | |||||
| return d.GetLastChild() | |||||
| } | |||||
| func GetNextSibling() *dom.Element { | |||||
| return d.GetNextSibling() | |||||
| } | |||||
| func GetPreviousSibling() *dom.Element { | |||||
| return d.GetPreviousSibling() | |||||
| } | |||||
| func GetParentElement() *dom.Element { | |||||
| return d.GetParentElement() | |||||
| } | |||||
| func GetRootElement() *dom.Element { | |||||
| return d.GetRootElement() | |||||
| } | |||||
| func GetPrefix() string { | |||||
| return d.GetPrefix() | |||||
| } | |||||
| func GetNodeName() string { | |||||
| return d.GetNodeName() | |||||
| } | |||||
| func GetTextContent() string { | |||||
| return d.GetTextContent() | |||||
| } | |||||
| func SetTextContent(v string) { | |||||
| d.SetTextContent(v) | |||||
| } | |||||
| func QuerySelector(selector string) *dom.Element { | |||||
| return d.QuerySelector(selector) | |||||
| } | |||||
| func QuerySelectorAll(selector string) []*dom.Element { | |||||
| return d.QuerySelectorAll(selector) | |||||
| } | |||||
| func AttachShadow(shadowRootInit dom.ShadowRootInit) *dom.ShadowRoot { | |||||
| return d.AttachShadow(shadowRootInit) | |||||
| } | |||||
| func GetClassName() string { | |||||
| return d.GetClassName() | |||||
| } | |||||
| func SetClassName(v string) { | |||||
| d.SetClassName(v) | |||||
| } | |||||
| func GetId() string { | |||||
| return d.GetId() | |||||
| } | |||||
| func SetId(v string) { | |||||
| d.SetId(v) | |||||
| } | |||||
| @ -1,98 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Element struct { | |||||
| Value | |||||
| } | |||||
| func NewElement(v js.Value) *Element { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToElement() | |||||
| } | |||||
| func (v Value) ToElement() *Element { return &Element{Value: v} } | |||||
| func (e *Element) AddEventListener(t string, listener *Callback) Value { | |||||
| val := Value{Value: e.Call("addEventListener", ToJSValue(t), ToJSValue(listener))} | |||||
| return val | |||||
| } | |||||
| func (e *Element) AppendChild(aChild *Element) *Element { | |||||
| val := Value{Value: e.Call("appendChild", ToJSValue(aChild))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetBaseURI() string { | |||||
| val := Value{Value: e.Get("baseURI")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) GetFirstChild() *Element { | |||||
| val := Value{Value: e.Get("firstChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetLastChild() *Element { | |||||
| val := Value{Value: e.Get("lastChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetNextSibling() *Element { | |||||
| val := Value{Value: e.Get("nextSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetPreviousSibling() *Element { | |||||
| val := Value{Value: e.Get("previousSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetParentElement() *Element { | |||||
| val := Value{Value: e.Get("parentElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetRootElement() *Element { | |||||
| val := Value{Value: e.Get("rootElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetPrefix() string { | |||||
| val := Value{Value: e.Get("prefix")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) GetNodeName() string { | |||||
| val := Value{Value: e.Get("nodeName")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) GetTextContent() string { | |||||
| val := Value{Value: e.Get("textContent")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) SetTextContent(v string) { | |||||
| e.Set("textContent", v) | |||||
| } | |||||
| func (e *Element) QuerySelector(selector string) *Element { | |||||
| val := Value{Value: e.Call("querySelector", ToJSValue(selector))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (e *Element) QuerySelectorAll(selector string) []*Element { | |||||
| val := Value{Value: e.Call("querySelectorAll", ToJSValue(selector))} | |||||
| elms := make([]*Element, 0) | |||||
| for i := 0; i < val.Length(); i += 1 { | |||||
| elms = append(elms, NewElement(val.Index(i))) | |||||
| } | |||||
| return elms | |||||
| } | |||||
| func (e *Element) AttachShadow(shadowRootInit ShadowRootInit) *ShadowRoot { | |||||
| val := Value{Value: e.Call("attachShadow", ToJSValue(shadowRootInit))} | |||||
| return NewShadowRoot(val.JSValue()) | |||||
| } | |||||
| func (e *Element) GetClassName() string { | |||||
| val := Value{Value: e.Get("className")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) SetClassName(v string) { | |||||
| e.Set("className", v) | |||||
| } | |||||
| func (e *Element) GetId() string { | |||||
| val := Value{Value: e.Get("id")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Element) SetId(v string) { | |||||
| e.Set("id", v) | |||||
| } | |||||
| @ -1,8 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| type ElementIFace interface { | |||||
| QuerySelector(selector string) *Element | |||||
| QuerySelectorAll(selector string) []*Element | |||||
| AttachShadow(shadowRootInit ShadowRootInit) *ShadowRoot | |||||
| } | |||||
| @ -1,45 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Event struct { | |||||
| Value | |||||
| } | |||||
| func NewEvent(v js.Value) *Event { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToEvent() | |||||
| } | |||||
| func (v Value) ToEvent() *Event { return &Event{Value: v} } | |||||
| func (e *Event) PreventDefault() Value { | |||||
| val := Value{Value: e.Call("preventDefault")} | |||||
| return val | |||||
| } | |||||
| func (e *Event) StopPropagation() Value { | |||||
| val := Value{Value: e.Call("stopPropagation")} | |||||
| return val | |||||
| } | |||||
| func (e *Event) StopImmediatePropagation() Value { | |||||
| val := Value{Value: e.Call("stopImmediatePropagation")} | |||||
| return val | |||||
| } | |||||
| func (e *Event) GetCurrentTarget() Value { | |||||
| val := Value{Value: e.Get("currentTarget")} | |||||
| return val | |||||
| } | |||||
| func (e *Event) GetTarget() Value { | |||||
| val := Value{Value: e.Get("target")} | |||||
| return val | |||||
| } | |||||
| func (e *Event) GetType() string { | |||||
| val := Value{Value: e.Get("type")} | |||||
| return val.String() | |||||
| } | |||||
| func (e *Event) GetSrcElement() Value { | |||||
| val := Value{Value: e.Get("srcElement")} | |||||
| return val | |||||
| } | |||||
| @ -1,8 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| type EventIFace interface { | |||||
| PreventDefault() | |||||
| StopPropagation() | |||||
| StopImmediatePropagation() | |||||
| } | |||||
| @ -1,6 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| type EventTargetIFace interface { | |||||
| AddEventListener(t string, listener *Callback) | |||||
| } | |||||
| @ -1,2 +0,0 @@ | |||||
| //go:generate go run generate/main.go | |||||
| package dom | |||||
| @ -1,68 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Node struct { | |||||
| Value | |||||
| } | |||||
| func NewNode(v js.Value) *Node { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToNode() | |||||
| } | |||||
| func (v Value) ToNode() *Node { return &Node{Value: v} } | |||||
| func (n *Node) AddEventListener(t string, listener *Callback) Value { | |||||
| val := Value{Value: n.Call("addEventListener", ToJSValue(t), ToJSValue(listener))} | |||||
| return val | |||||
| } | |||||
| func (n *Node) AppendChild(aChild *Element) *Element { | |||||
| val := Value{Value: n.Call("appendChild", ToJSValue(aChild))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetBaseURI() string { | |||||
| val := Value{Value: n.Get("baseURI")} | |||||
| return val.String() | |||||
| } | |||||
| func (n *Node) GetFirstChild() *Element { | |||||
| val := Value{Value: n.Get("firstChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetLastChild() *Element { | |||||
| val := Value{Value: n.Get("lastChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetNextSibling() *Element { | |||||
| val := Value{Value: n.Get("nextSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetPreviousSibling() *Element { | |||||
| val := Value{Value: n.Get("previousSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetParentElement() *Element { | |||||
| val := Value{Value: n.Get("parentElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetRootElement() *Element { | |||||
| val := Value{Value: n.Get("rootElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (n *Node) GetPrefix() string { | |||||
| val := Value{Value: n.Get("prefix")} | |||||
| return val.String() | |||||
| } | |||||
| func (n *Node) GetNodeName() string { | |||||
| val := Value{Value: n.Get("nodeName")} | |||||
| return val.String() | |||||
| } | |||||
| func (n *Node) GetTextContent() string { | |||||
| val := Value{Value: n.Get("textContent")} | |||||
| return val.String() | |||||
| } | |||||
| func (n *Node) SetTextContent(v string) { | |||||
| n.Set("textContent", v) | |||||
| } | |||||
| @ -1,6 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| type NodeIFace interface { | |||||
| AppendChild(aChild *Element) *Element | |||||
| } | |||||
| @ -1,17 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Promise struct { | |||||
| Value | |||||
| } | |||||
| func NewPromise(v js.Value) *Promise { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToPromise() | |||||
| } | |||||
| func (v Value) ToPromise() *Promise { return &Promise{Value: v} } | |||||
| @ -1,83 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type ShadowRoot struct { | |||||
| Value | |||||
| } | |||||
| func NewShadowRoot(v js.Value) *ShadowRoot { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToShadowRoot() | |||||
| } | |||||
| func (v Value) ToShadowRoot() *ShadowRoot { return &ShadowRoot{Value: v} } | |||||
| func (s *ShadowRoot) GetMode() string { | |||||
| val := Value{Value: s.Get("mode")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) GetHost() *Element { | |||||
| val := Value{Value: s.Get("host")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetInnerHTML() string { | |||||
| val := Value{Value: s.Get("innerHTML")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) SetInnerHTML(v string) { | |||||
| s.Set("innerHTML", v) | |||||
| } | |||||
| func (s *ShadowRoot) AddEventListener(t string, listener *Callback) Value { | |||||
| val := Value{Value: s.Call("addEventListener", ToJSValue(t), ToJSValue(listener))} | |||||
| return val | |||||
| } | |||||
| func (s *ShadowRoot) AppendChild(aChild *Element) *Element { | |||||
| val := Value{Value: s.Call("appendChild", ToJSValue(aChild))} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetBaseURI() string { | |||||
| val := Value{Value: s.Get("baseURI")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) GetFirstChild() *Element { | |||||
| val := Value{Value: s.Get("firstChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetLastChild() *Element { | |||||
| val := Value{Value: s.Get("lastChild")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetNextSibling() *Element { | |||||
| val := Value{Value: s.Get("nextSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetPreviousSibling() *Element { | |||||
| val := Value{Value: s.Get("previousSibling")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetParentElement() *Element { | |||||
| val := Value{Value: s.Get("parentElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetRootElement() *Element { | |||||
| val := Value{Value: s.Get("rootElement")} | |||||
| return NewElement(val.JSValue()) | |||||
| } | |||||
| func (s *ShadowRoot) GetPrefix() string { | |||||
| val := Value{Value: s.Get("prefix")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) GetNodeName() string { | |||||
| val := Value{Value: s.Get("nodeName")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) GetTextContent() string { | |||||
| val := Value{Value: s.Get("textContent")} | |||||
| return val.String() | |||||
| } | |||||
| func (s *ShadowRoot) SetTextContent(v string) { | |||||
| s.Set("textContent", v) | |||||
| } | |||||
| @ -1,14 +0,0 @@ | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type ShadowRootInit struct { | |||||
| Value | |||||
| Mode string | |||||
| } | |||||
| func (s ShadowRootInit) JSValue() js.Value { | |||||
| v := js.Global().Get("Object").New() | |||||
| v.Set("mode", s.Mode) | |||||
| return v | |||||
| } | |||||
| @ -1,29 +0,0 @@ | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type JSValue interface { | |||||
| JSValue() js.Value | |||||
| } | |||||
| func ToJSValue(x interface{}) js.Value { | |||||
| if v, ok := x.(JSValue); ok { | |||||
| return v.JSValue() | |||||
| } | |||||
| return js.ValueOf(x) | |||||
| } | |||||
| type Value struct { | |||||
| js.Value | |||||
| } | |||||
| func (v Value) JSValue() js.Value { return v.Value } | |||||
| func (v Value) IsUndefined() bool { return v.Type() == js.TypeUndefined } | |||||
| func (v Value) IsNull() bool { return v.Type() == js.TypeNull } | |||||
| func (v Value) IsBoolean() bool { return v.Type() == js.TypeBoolean } | |||||
| func (v Value) IsNumber() bool { return v.Type() == js.TypeNumber } | |||||
| func (v Value) IsString() bool { return v.Type() == js.TypeString } | |||||
| func (v Value) IsSymbol() bool { return v.Type() == js.TypeSymbol } | |||||
| func (v Value) IsObject() bool { return v.Type() == js.TypeObject } | |||||
| func (v Value) IsFunction() bool { return v.Type() == js.TypeFunction } | |||||
| @ -1,17 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package dom | |||||
| import "syscall/js" | |||||
| type Window struct { | |||||
| Value | |||||
| } | |||||
| func NewWindow(v js.Value) *Window { | |||||
| val := Value{Value: v} | |||||
| if val.IsNull() || val.IsUndefined() { | |||||
| return nil | |||||
| } | |||||
| return val.ToWindow() | |||||
| } | |||||
| func (v Value) ToWindow() *Window { return &Window{Value: v} } | |||||
| @ -1,11 +0,0 @@ | |||||
| // DO NOT EDIT - generated file | |||||
| package window | |||||
| import "syscall/js" | |||||
| import dom "github.com/brettlangdon/go-dom/v1" | |||||
| var w *dom.Window | |||||
| func init() { | |||||
| w = dom.NewWindow(js.Global().Get("window")) | |||||
| } | |||||