rss-tools/vendor/github.com/PuerkitoBio/goquery/expand.go (view raw)
| 1 | package goquery |
| 2 | |
| 3 | import "golang.org/x/net/html" |
| 4 | |
| 5 | // Add adds the selector string's matching nodes to those in the current |
| 6 | // selection and returns a new Selection object. |
| 7 | // The selector string is run in the context of the document of the current |
| 8 | // Selection object. |
| 9 | func (s *Selection) Add(selector string) *Selection { |
| 10 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, compileMatcher(selector))...) |
| 11 | } |
| 12 | |
| 13 | // AddMatcher adds the matcher's matching nodes to those in the current |
| 14 | // selection and returns a new Selection object. |
| 15 | // The matcher is run in the context of the document of the current |
| 16 | // Selection object. |
| 17 | func (s *Selection) AddMatcher(m Matcher) *Selection { |
| 18 | return s.AddNodes(findWithMatcher([]*html.Node{s.document.rootNode}, m)...) |
| 19 | } |
| 20 | |
| 21 | // AddSelection adds the specified Selection object's nodes to those in the |
| 22 | // current selection and returns a new Selection object. |
| 23 | func (s *Selection) AddSelection(sel *Selection) *Selection { |
| 24 | if sel == nil { |
| 25 | return s.AddNodes() |
| 26 | } |
| 27 | return s.AddNodes(sel.Nodes...) |
| 28 | } |
| 29 | |
| 30 | // Union is an alias for AddSelection. |
| 31 | func (s *Selection) Union(sel *Selection) *Selection { |
| 32 | return s.AddSelection(sel) |
| 33 | } |
| 34 | |
| 35 | // AddNodes adds the specified nodes to those in the |
| 36 | // current selection and returns a new Selection object. |
| 37 | func (s *Selection) AddNodes(nodes ...*html.Node) *Selection { |
| 38 | return pushStack(s, appendWithoutDuplicates(s.Nodes, nodes, nil)) |
| 39 | } |
| 40 | |
| 41 | // AndSelf adds the previous set of elements on the stack to the current set. |
| 42 | // It returns a new Selection object containing the current Selection combined |
| 43 | // with the previous one. |
| 44 | // Deprecated: This function has been deprecated and is now an alias for AddBack(). |
| 45 | func (s *Selection) AndSelf() *Selection { |
| 46 | return s.AddBack() |
| 47 | } |
| 48 | |
| 49 | // AddBack adds the previous set of elements on the stack to the current set. |
| 50 | // It returns a new Selection object containing the current Selection combined |
| 51 | // with the previous one. |
| 52 | func (s *Selection) AddBack() *Selection { |
| 53 | return s.AddSelection(s.prevSel) |
| 54 | } |
| 55 | |
| 56 | // AddBackFiltered reduces the previous set of elements on the stack to those that |
| 57 | // match the selector string, and adds them to the current set. |
| 58 | // It returns a new Selection object containing the current Selection combined |
| 59 | // with the filtered previous one |
| 60 | func (s *Selection) AddBackFiltered(selector string) *Selection { |
| 61 | return s.AddSelection(s.prevSel.Filter(selector)) |
| 62 | } |
| 63 | |
| 64 | // AddBackMatcher reduces the previous set of elements on the stack to those that match |
| 65 | // the matcher, and adds them to the current set. |
| 66 | // It returns a new Selection object containing the current Selection combined |
| 67 | // with the filtered previous one |
| 68 | func (s *Selection) AddBackMatcher(m Matcher) *Selection { |
| 69 | return s.AddSelection(s.prevSel.FilterMatcher(m)) |
| 70 | } |