diff --git a/query.go b/query.go index fe86bf0..293afeb 100644 --- a/query.go +++ b/query.go @@ -24,19 +24,32 @@ func (s *Selection) IsMatcher(m Matcher) bool { // 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 + for i, n := range s.Nodes { + if f(i, newSingleSelection(n, s.document)) { + return true + } + } + return false } // 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 + if sel == nil { + return false + } + return s.IsNodes(sel.Nodes...) } // 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 + for _, n := range s.Nodes { + if isInSlice(nodes, n) { + return true + } + } + return false } // Contains returns true if the specified Node is within,