Skip to content

Add HTMLDialogElement, HTMLPictureElement,, HTMLSlotElement #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions dom.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ func wrapHTMLElement(o *js.Object) HTMLElement {
return &HTMLDataElement{BasicHTMLElement: el}
case js.Global.Get("HTMLDataListElement"):
return &HTMLDataListElement{BasicHTMLElement: el}
case js.Global.Get("HTMLDialogElement"):
return &HTMLDialogElement{BasicHTMLElement: el}
case js.Global.Get("HTMLDirectoryElement"):
return &HTMLDirectoryElement{BasicHTMLElement: el}
case js.Global.Get("HTMLDivElement"):
Expand Down Expand Up @@ -358,6 +360,8 @@ func wrapHTMLElement(o *js.Object) HTMLElement {
return &HTMLParagraphElement{BasicHTMLElement: el}
case js.Global.Get("HTMLParamElement"):
return &HTMLParamElement{BasicHTMLElement: el}
case js.Global.Get("HTMLPictureElement"):
return &HTMLPictureElement{BasicHTMLElement: el}
case js.Global.Get("HTMLPreElement"):
return &HTMLPreElement{BasicHTMLElement: el}
case js.Global.Get("HTMLProgressElement"):
Expand All @@ -368,6 +372,8 @@ func wrapHTMLElement(o *js.Object) HTMLElement {
return &HTMLScriptElement{BasicHTMLElement: el}
case js.Global.Get("HTMLSelectElement"):
return &HTMLSelectElement{BasicHTMLElement: el}
case js.Global.Get("HTMLSlotElement"):
return &HTMLSlotElement{BasicHTMLElement: el}
case js.Global.Get("HTMLSourceElement"):
return &HTMLSourceElement{BasicHTMLElement: el}
case js.Global.Get("HTMLSpanElement"):
Expand All @@ -390,6 +396,8 @@ func wrapHTMLElement(o *js.Object) HTMLElement {
return &HTMLTableRowElement{BasicHTMLElement: el}
case js.Global.Get("HTMLTableSectionElement"):
return &HTMLTableSectionElement{BasicHTMLElement: el}
case js.Global.Get("HTMLTemplateElement"):
return &HTMLTemplateElement{BasicHTMLElement: el}
case js.Global.Get("HTMLTextAreaElement"):
return &HTMLTextAreaElement{BasicHTMLElement: el}
case js.Global.Get("HTMLTimeElement"):
Expand Down Expand Up @@ -1516,6 +1524,7 @@ type Element interface {

Attributes() map[string]string
Class() *TokenList
Closest(string) Element
ID() string
SetID(string)
TagName() string
Expand All @@ -1527,6 +1536,7 @@ type Element interface {
GetElementsByTagNameNS(ns string, name string) []Element
HasAttribute(string) bool
HasAttributeNS(ns string, name string) bool
Matches(string) bool
QuerySelector(string) Element
QuerySelectorAll(string) []Element
RemoveAttribute(string)
Expand Down Expand Up @@ -1719,6 +1729,10 @@ func (e *BasicElement) SetClass(s string) {
e.Set("className", s)
}

func (e *BasicElement) Closest(s string) Element {
return wrapElement(e.Call("closest", s))
}

func (e *BasicElement) ID() string {
return e.Get("id").String()
}
Expand Down Expand Up @@ -1759,6 +1773,10 @@ func (e *BasicElement) HasAttributeNS(ns string, name string) bool {
return e.Call("hasAttributeNS", ns, name).Bool()
}

func (e *BasicElement) Matches(s string) bool {
return e.Call("matches", s).Bool()
}

func (e *BasicElement) QuerySelector(s string) Element {
return wrapElement(e.Call("querySelector", s))
}
Expand Down Expand Up @@ -2294,6 +2312,24 @@ func (e *HTMLDataListElement) Options() []*HTMLOptionElement {
return getOptions(e.Object, "options")
}

type HTMLDialogElement struct {
*BasicHTMLElement
Open bool `js:"open"`
ReturnValue string `js:"returnValue"`
}

func (e *HTMLDialogElement) Close(returnValue string) {
e.Call("close", returnValue)
}

func (e *HTMLDialogElement) Show() {
e.Call("show")
}

func (e *HTMLDialogElement) ShowModal() {
e.Call("showModal")
}

type HTMLDirectoryElement struct{ *BasicHTMLElement }
type HTMLDivElement struct{ *BasicHTMLElement }

Expand Down Expand Up @@ -2766,6 +2802,7 @@ type HTMLParamElement struct {
Value string `js:"value"`
}

type HTMLPictureElement struct{ *BasicHTMLElement }
type HTMLPreElement struct{ *BasicHTMLElement }

type HTMLProgressElement struct {
Expand Down Expand Up @@ -2859,6 +2896,15 @@ func (e *HTMLSelectElement) SetCustomValidity(s string) {
e.Call("setCustomValidity", s)
}

type HTMLSlotElement struct {
*BasicHTMLElement
Name string `js:"name"`
}

func (e *HTMLSlotElement) AssignedNodes() []Element {
return nodeListToElements(e.Call("assignedNodes"))
}

type HTMLSourceElement struct {
*BasicHTMLElement
Media string `js:"media"`
Expand Down Expand Up @@ -2936,6 +2982,12 @@ func (e *HTMLTableSectionElement) InsertRow(index int) *HTMLTableRowElement {
return wrapHTMLElement(e.Call("insertRow", index)).(*HTMLTableRowElement)
}

type HTMLTemplateElement struct{ *BasicHTMLElement }

func (e *HTMLTemplateElement) Content() DocumentFragment {
return wrapDocumentFragment(e.Get("content"))
}

type HTMLTextAreaElement struct {
*BasicHTMLElement
Autocomplete string `js:"autocomplete"`
Expand Down