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:
parent
de85784097
commit
9ac16e2e4f
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue