Basic boilerplate for descendant-or-self.

This commit is contained in:
Yorick Peterse 2014-07-25 21:24:29 +02:00
parent 766b35d9ce
commit 1916799fef
1 changed files with 19 additions and 1 deletions

View File

@ -218,7 +218,7 @@ module Oga
end
##
# Evaluator the `descendant` axis. This method processes child nodes until
# Evaluates the `descendant` axis. This method processes child nodes until
# the very end of the tree, no "short-circuiting" mechanism is used.
#
# @param [Oga::XPath::Node] node
@ -226,6 +226,24 @@ module Oga
# @return [Oga::XML::NodeSet]
#
def on_axis_descendant(node, context)
nodes = XML::NodeSet.new
children = child_nodes(context)
unless children.empty?
nodes += on_axis_descendant(node, children)
end
return nodes
end
##
# Evaluates the `descendant-or-self` axis.
#
# @param [Oga::XPath::Node] node
# @param [Oga::XML::NodeSet] context
# @return [Oga::XML::NodeSet]
#
def on_axis_descendant_or_self(node, context)
nodes = on_test(node, context)
children = child_nodes(context)