Refactor IsMatcher to use slices.ContainsFunc

This commit is contained in:
udf2457
2026-09-04 15:38:40 +01:00
committed by GitHub
parent 4a4f1326fa
commit 8cb3ddf6e3
+6 -7
View File
@@ -1,6 +1,10 @@
package goquery
import "golang.org/x/net/html"
import (
"slices"
"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.
@@ -11,12 +15,7 @@ func (s *Selection) Is(selector string) bool {
// 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 {
for _, n := range s.Nodes {
if m.Match(n) {
return true
}
}
return false
return slices.ContainsFunc(s.Nodes, m.Match)
}
// IsFunction checks the current matched set of elements against a predicate and