From ec897f4be07ce67d5859e738781d491e596510b1 Mon Sep 17 00:00:00 2001 From: Inkeliz Date: Sun, 23 Dec 2018 21:00:30 -0200 Subject: [PATCH] Add Element.Closest and Element.Matches --- dom.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dom.go b/dom.go index cc6f96d..3eeb055 100644 --- a/dom.go +++ b/dom.go @@ -1524,6 +1524,7 @@ type Element interface { Attributes() map[string]string Class() *TokenList + Closest(string) Element ID() string SetID(string) TagName() string @@ -1535,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) @@ -1727,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() } @@ -1767,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)) }