Skip to content

Commit 6e96fd6

Browse files
inkelizdmitshur
authored andcommitted
Add Element.Closest and Element.Matches
1 parent 6da835b commit 6e96fd6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

dom.go

+10
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,7 @@ type Element interface {
15161516

15171517
Attributes() map[string]string
15181518
Class() *TokenList
1519+
Closest(string) Element
15191520
ID() string
15201521
SetID(string)
15211522
TagName() string
@@ -1527,6 +1528,7 @@ type Element interface {
15271528
GetElementsByTagNameNS(ns string, name string) []Element
15281529
HasAttribute(string) bool
15291530
HasAttributeNS(ns string, name string) bool
1531+
Matches(string) bool
15301532
QuerySelector(string) Element
15311533
QuerySelectorAll(string) []Element
15321534
RemoveAttribute(string)
@@ -1719,6 +1721,10 @@ func (e *BasicElement) SetClass(s string) {
17191721
e.Set("className", s)
17201722
}
17211723

1724+
func (e *BasicElement) Closest(s string) Element {
1725+
return wrapElement(e.Call("closest", s))
1726+
}
1727+
17221728
func (e *BasicElement) ID() string {
17231729
return e.Get("id").String()
17241730
}
@@ -1759,6 +1765,10 @@ func (e *BasicElement) HasAttributeNS(ns string, name string) bool {
17591765
return e.Call("hasAttributeNS", ns, name).Bool()
17601766
}
17611767

1768+
func (e *BasicElement) Matches(s string) bool {
1769+
return e.Call("matches", s).Bool()
1770+
}
1771+
17621772
func (e *BasicElement) QuerySelector(s string) Element {
17631773
return wrapElement(e.Call("querySelector", s))
17641774
}

0 commit comments

Comments
 (0)