mirror of
https://github.com/PuerkitoBio/goquery.git
synced 2026-10-19 16:15:33 +00:00
Refactor IsMatcher to use slices.ContainsFunc
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user