forked from Shiloh/githaven
79494047b0
* Show commit status icon in commits table * Add comments * Fix icons * Few more places where commit table is displayed * Change integration test to use goquery for parsing html * Add integration tests for commit table and status icons * Fix status to return lates status correctly on all databases * Rewrote lates commit status selects
54 lines
1.7 KiB
Go
54 lines
1.7 KiB
Go
package goquery
|
|
|
|
import "golang.org/x/net/html"
|
|
|
|
// Is checks the current matched set of elements against a selector and
|
|
// returns true if at least one of these elements matches.
|
|
func (s *Selection) Is(selector string) bool {
|
|
if len(s.Nodes) > 0 {
|
|
return s.IsMatcher(compileMatcher(selector))
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// IsMatcher checks the current matched set of elements against a matcher and
|
|
// returns true if at least one of these elements matches.
|
|
func (s *Selection) IsMatcher(m Matcher) bool {
|
|
if len(s.Nodes) > 0 {
|
|
if len(s.Nodes) == 1 {
|
|
return m.Match(s.Nodes[0])
|
|
}
|
|
return len(m.Filter(s.Nodes)) > 0
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// IsFunction checks the current matched set of elements against a predicate and
|
|
// returns true if at least one of these elements matches.
|
|
func (s *Selection) IsFunction(f func(int, *Selection) bool) bool {
|
|
return s.FilterFunction(f).Length() > 0
|
|
}
|
|
|
|
// IsSelection checks the current matched set of elements against a Selection object
|
|
// and returns true if at least one of these elements matches.
|
|
func (s *Selection) IsSelection(sel *Selection) bool {
|
|
return s.FilterSelection(sel).Length() > 0
|
|
}
|
|
|
|
// IsNodes checks the current matched set of elements against the specified nodes
|
|
// and returns true if at least one of these elements matches.
|
|
func (s *Selection) IsNodes(nodes ...*html.Node) bool {
|
|
return s.FilterNodes(nodes...).Length() > 0
|
|
}
|
|
|
|
// 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 (s *Selection) Contains(n *html.Node) bool {
|
|
return sliceContains(s.Nodes, n)
|
|
}
|