work on filter.go, needs tests now

This commit is contained in:
Martin Angers
2012-08-30 22:47:12 -04:00
parent 503306d8a5
commit 437a1dc2a1
4 changed files with 81 additions and 50 deletions

View File

@@ -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)
}