Skip to content

Commit

Permalink
fix | with /text() for the duplicate text value. antchfx/htmlquer…
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengchun committed Apr 16, 2020
1 parent bb56b50 commit a015dcb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,18 @@ func getHashCode(n NodeNavigator) uint64 {
switch n.NodeType() {
case AttributeNode, TextNode, CommentNode:
sb.WriteString(fmt.Sprintf("%s=%s", n.LocalName(), n.Value()))
if n.MoveToParent() {
sb.WriteString(n.LocalName())
// https://github.com/antchfx/htmlquery/issues/25
d := 1
for n.MoveToPrevious() {
d++
}
sb.WriteString(fmt.Sprintf("-%d", d))
for n.MoveToParent() {
d = 1
for n.MoveToPrevious() {
d++
}
sb.WriteString(fmt.Sprintf("-%d", d))
}
case ElementNode:
sb.WriteString(n.Prefix() + n.LocalName())
Expand Down

0 comments on commit a015dcb

Please sign in to comment.