diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 3cb68c9..6eb36a4 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -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)