Internal implementation of sibling nodes that return a raw slice of matches.
(nodes []*html.Node, st siblingType, untilm Matcher, untilNodes []*html.Node)
| 582 | |
| 583 | // Internal implementation of sibling nodes that return a raw slice of matches. |
| 584 | func getSiblingNodes(nodes []*html.Node, st siblingType, untilm Matcher, untilNodes []*html.Node) []*html.Node { |
| 585 | var f func(*html.Node) bool |
| 586 | |
| 587 | // If the requested siblings are ...Until, create the test function to |
| 588 | // determine if the until condition is reached (returns true if it is) |
| 589 | if st == siblingNextUntil || st == siblingPrevUntil { |
| 590 | f = func(n *html.Node) bool { |
| 591 | if untilm != nil { |
| 592 | // Matcher-based condition |
| 593 | sel := newSingleSelection(n, nil) |
| 594 | return sel.IsMatcher(untilm) |
| 595 | } else if len(untilNodes) > 0 { |
| 596 | // Nodes-based condition |
| 597 | sel := newSingleSelection(n, nil) |
| 598 | return sel.IsNodes(untilNodes...) |
| 599 | } |
| 600 | return false |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | return mapNodes(nodes, func(i int, n *html.Node) []*html.Node { |
| 605 | return getChildrenWithSiblingType(n.Parent, st, n, f) |
| 606 | }) |
| 607 | } |
| 608 | |
| 609 | // Gets the children nodes of each node in the specified slice of nodes, |
| 610 | // based on the sibling type request. |
no test coverage detected
searching dependent graphs…