Fixed index check in Node#next

An index can/should never be equal the length of a NodeSet, thus we
should use "<" here instead of "<=".
This commit is contained in:
Yorick Peterse 2016-09-03 23:56:55 +02:00
parent de85784097
commit 9ac16e2e4f
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
2 changed files with 2 additions and 2 deletions

View File

@ -70,7 +70,7 @@ module Oga
index = node_set.index(self) + 1 index = node_set.index(self) + 1
length = node_set.length length = node_set.length
index <= length ? node_set[index] : nil index < length ? node_set[index] : nil
end end
# Returns the previous element node or nil if there is none. # Returns the previous element node or nil if there is none.

View File

@ -86,7 +86,7 @@ describe Oga::XML::Node do
@n1.next.should == @n2 @n1.next.should == @n2
end end
it 'returns nil if there is no previous node' do it 'returns nil if there is no next node' do
@n2.next.nil?.should == true @n2.next.nil?.should == true
end end
end end