Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rexml/xpath_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def sort(array_of_nodes, order)
if order == :forward
index
else
-index
index.map(&:-@)
end
end
ordered.collect do |_index, node|
Expand Down
6 changes: 6 additions & 0 deletions test/xpath/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ def test_preceding
assert_equal( 4, cs.length )
end

def test_preceding_sibling
d = REXML::Document.new("<a><b><c/><d/><x/></b><b><e/><x/></b></a>")
matches = REXML::XPath.match(d, "a/b/x/preceding-sibling::node()")
assert_equal(["e", "d", "c"], matches.map(&:name))
end

def test_following
d = Document.new "<a><b id='0'/><b/><b><c id='1'/><c id='2'/></b><b id='1'/></a>"
start = XPath.first( d, "/a/b[@id='0']" )
Expand Down
Loading