mirror of
https://github.com/PuerkitoBio/goquery
synced 2025-10-05 08:46:53 +08:00
work on filter.go, needs tests now
This commit is contained in:
18
query.go
18
query.go
@@ -24,3 +24,21 @@ func (this *Selection) HasClass(class string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Contains() returns true if the specified Node is within,
|
||||
// at any depth, one of the nodes in the Selection object.
|
||||
// It is NOT inclusive, to behave like jQuery's implementation, and
|
||||
// unlike Javascript's .contains(), so if the contained
|
||||
// node is itself in the selection, it returns false.
|
||||
func (this *Selection) Contains(n *html.Node) bool {
|
||||
return sliceContains(this.Nodes, n)
|
||||
}
|
||||
|
||||
// Contains() returns true if the specified Node is within,
|
||||
// at any depth, the root node of the Document object.
|
||||
// It is NOT inclusive, to behave like jQuery's implementation, and
|
||||
// unlike Javascript's .contains(), so if the contained
|
||||
// node is itself in the selection, it returns false.
|
||||
func (this *Document) Contains(n *html.Node) bool {
|
||||
return sliceContains([]*html.Node{this.Root}, n)
|
||||
}
|
||||
|
Reference in New Issue
Block a user