on_call_last() should return an index, not a node.
This commit is contained in:
parent
423af37422
commit
202f74a8eb
|
@ -549,18 +549,15 @@ module Oga
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Processes the `last()` function call. This function call returns a node
|
# Processes the `last()` function call. This function call returns the
|
||||||
# set containing the last node of the context set.
|
# index of the last node in the current set.
|
||||||
#
|
#
|
||||||
# @param [Oga::XML::NodeSet] context
|
# @param [Oga::XML::NodeSet] context
|
||||||
# @return [Oga::XML::NodeSet]
|
# @return [Float]
|
||||||
#
|
#
|
||||||
def on_call_last(context)
|
def on_call_last(context)
|
||||||
if context.empty?
|
# XPath uses indexes 1 to N instead of 0 to N.
|
||||||
return context
|
return context.length.to_f
|
||||||
else
|
|
||||||
return XML::NodeSet.new([context.last])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in New Issue