From 424a91ab920ae3cc8e870a14e79737e75bf0e4b8 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Wed, 29 Aug 2012 15:23:16 -0400 Subject: [PATCH] refactor to use the newly added Filter() and Match() in cascadia --- goquery.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/goquery.go b/goquery.go index 7ebae21..0f3f78d 100644 --- a/goquery.go +++ b/goquery.go @@ -168,21 +168,13 @@ func (this *Selection) ChildrenFiltered(selector string) *Selection { } func (this *Selection) Filter(selector string) *Selection { - var matches []*html.Node - sel, e := cascadia.Compile(selector) if e != nil { // Selector doesn't compile, which means empty selection return &Selection{nil, this.document} } - // Check for a match for each current selection - for _, n := range this.Nodes { - if sel(n) { - matches = append(matches, n) - } - } - return &Selection{matches, this.document} + return &Selection{sel.Filter(this.Nodes), this.document} } func (this *Selection) FilterFunction(f func(int, *Selection) bool) *Selection {