MatchFirst returns the first node that matches s, from n and its children.
(n *html.Node)
| 159 | |
| 160 | // MatchFirst returns the first node that matches s, from n and its children. |
| 161 | func (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. |