MCPcopy
hub / github.com/PuerkitoBio/goquery / getSiblingNodes

Function getSiblingNodes

traversal.go:584–607  ·  view source on GitHub ↗

Internal implementation of sibling nodes that return a raw slice of matches.

(nodes []*html.Node, st siblingType, untilm Matcher, untilNodes []*html.Node)

Source from the content-addressed store, hash-verified

582
583// Internal implementation of sibling nodes that return a raw slice of matches.
584func 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.

Callers 15

SiblingsMethod · 0.85
SiblingsFilteredMethod · 0.85
SiblingsMatcherMethod · 0.85
NextMethod · 0.85
NextFilteredMethod · 0.85
NextMatcherMethod · 0.85
NextAllMethod · 0.85
NextAllFilteredMethod · 0.85
NextAllMatcherMethod · 0.85
PrevMethod · 0.85
PrevFilteredMethod · 0.85
PrevMatcherMethod · 0.85

Calls 5

newSingleSelectionFunction · 0.85
mapNodesFunction · 0.85
IsMatcherMethod · 0.80
IsNodesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…