diff --git a/lib/oga/xpath/compiler.rb b/lib/oga/xpath/compiler.rb index 7263433..ecf2501 100644 --- a/lib/oga/xpath/compiler.rb +++ b/lib/oga/xpath/compiler.rb @@ -214,6 +214,20 @@ module Oga end end + # @param [AST::Node] ast + # @param [Oga::Ruby::Node] input + # @return [Oga::Ruby::Node] + def on_axis_descendant_or_self(ast, input, &block) + descendant = node_literal + self_test = process(ast, input, &block).if_true { yield input } + + descendants_test = input.each_node.add_block(descendant) do + process(ast, descendant, &block).if_true { yield descendant } + end + + self_test.followed_by(descendants_test) + end + # @param [AST::Node] ast # @param [Oga::Ruby::Node] input # @return [Oga::Ruby::Node]