Skip to content

Commit

Permalink
Merge branch '#72'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengchun committed Mar 25, 2022
2 parents 696d123 + 2c9e2d2 commit 5da9b3e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func axisPredicate(root *axisNode) func(NodeNavigator) bool {
}
nametest := root.LocalName != "" || root.Prefix != ""
predicate := func(n NodeNavigator) bool {
if typ == n.NodeType() || typ == allNode || typ == TextNode {
if typ == n.NodeType() || typ == allNode {
if nametest {
if root.LocalName == n.LocalName() && root.Prefix == n.Prefix() {
return true
Expand Down
16 changes: 13 additions & 3 deletions xpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ func TestAncestor(t *testing.T) {

func TestFollowingSibling(t *testing.T) {
var list []*TNode
list = selectNodes(html2, "//h1/span/following-sibling::text()")
for _, n := range list {
if n.Type != TextNode {
t.Errorf("expected node is text but got:%s nodes %d", n.Data, len(list))
}
}
list = selectNodes(html, "//li/following-sibling::*")
for _, n := range list {
if n.Data != "li" {
Expand Down Expand Up @@ -628,7 +634,7 @@ func example2() *TNode {
<meta name="language" content="en"/>
</head>
<body>
<h1> This is a H1 </h1>
<h1><span>SPAN</span><a>Anchor</a> This is a H1 </h1>
<table>
<tbody>
<tr>
Expand Down Expand Up @@ -664,8 +670,12 @@ func example2() *TNode {
n.addAttribute("content", "en")
// The HTML body section.
body := xhtml.createChildNode("body", ElementNode)
n = body.createChildNode("h1", ElementNode)
n = n.createChildNode(" This is a H1 ", TextNode)
h1 := body.createChildNode("h1", ElementNode)
n = h1.createChildNode("span", ElementNode)
n = n.createChildNode("SPAN", TextNode)
n = h1.createChildNode("a", ElementNode)
n = n.createChildNode("Anchor", TextNode)
h1.createChildNode(" This is a H1 ", TextNode)

n = body.createChildNode("table", ElementNode)
tbody := n.createChildNode("tbody", ElementNode)
Expand Down

0 comments on commit 5da9b3e

Please sign in to comment.