mirror of
https://github.com/PuerkitoBio/goquery
synced 2025-10-04 08:26:37 +08:00
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package goquery
|
|
|
|
import (
|
|
"exp/html"
|
|
)
|
|
|
|
// Add() adds the selector string's matching nodes to those in the current
|
|
// selection and returns a new Selection object.
|
|
// The selector string is run in the context of the document of the current
|
|
// Selection object.
|
|
func (this *Selection) Add(selector string) *Selection {
|
|
return this.AddNodes(findWithContext(selector, this.document.Root)...)
|
|
}
|
|
|
|
// AddSelection() adds the specified Selection object's nodes to those in the
|
|
// current selection and returns a new Selection object.
|
|
func (this *Selection) AddSelection(sel *Selection) *Selection {
|
|
if sel == nil {
|
|
return this.AddNodes()
|
|
}
|
|
return this.AddNodes(sel.Nodes...)
|
|
}
|
|
|
|
// AddNodes() adds the specified nodes to those in the
|
|
// current selection and returns a new Selection object.
|
|
func (this *Selection) AddNodes(nodes ...*html.Node) *Selection {
|
|
return pushStack(this, appendWithoutDuplicates(this.Nodes, nodes))
|
|
}
|
|
|
|
// AndSelf() adds the previous set of elements on the stack to the current set.
|
|
// It returns a new Selection object containing the current Selection combined
|
|
// with the previous one.
|
|
func (this *Selection) AndSelf() *Selection {
|
|
return this.AddSelection(this.prevSel)
|
|
}
|