From ba368a603dd4fbdce369eb76a2636e41444a929b Mon Sep 17 00:00:00 2001 From: zhengchun Date: Mon, 19 Sep 2022 20:17:35 +0800 Subject: [PATCH] fix https://github.com/antchfx/htmlquery/issues/52 Skip the current node(Self:false) for the next descendants nodes. --- build.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.go b/build.go index 0a002ad..561719c 100644 --- a/build.go +++ b/build.go @@ -88,7 +88,10 @@ func (b *builder) processAxisNode(root *axisNode) (query, error) { } return v } - qyOutput = &descendantQuery{Input: qyGrandInput, Predicate: filter, Self: true} + // fix `//*[contains(@id,"food")]//*[contains(@id,"food")]`, see https://github.com/antchfx/htmlquery/issues/52 + // Skip the current node(Self:false) for the next descendants nodes. + _, ok := qyGrandInput.(*contextQuery) + qyOutput = &descendantQuery{Input: qyGrandInput, Predicate: filter, Self: ok} return qyOutput, nil } }