Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Following Sibling): Following Sibling does not work properly when… #72

Merged
merged 1 commit into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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