MCPcopy Create free account
hub / github.com/andybalholm/cascadia / MatchFirst

Method MatchFirst

selector.go:161–173  ·  view source on GitHub ↗

MatchFirst returns the first node that matches s, from n and its children.

(n *html.Node)

Source from the content-addressed store, hash-verified

159
160// MatchFirst returns the first node that matches s, from n and its children.
161func (s Selector) MatchFirst(n *html.Node) *html.Node {
162 if s.Match(n) {
163 return n
164 }
165
166 for c := n.FirstChild; c != nil; c = c.NextSibling {
167 m := s.MatchFirst(c)
168 if m != nil {
169 return m
170 }
171 }
172 return nil
173}
174
175// Query returns the first node that matches m, from the descendants of n.
176// If none matches, it returns nil.

Callers 1

TestSelectorsFunction · 0.80

Calls 1

MatchMethod · 0.95

Tested by 1

TestSelectorsFunction · 0.64