From ca7930cbf4e0b00eca8c25d07fcd92e56ed4a196 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 3 Aug 2015 09:29:32 +0200 Subject: [PATCH] XPath compiler support for "descendant" --- lib/oga/xpath/compiler.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/oga/xpath/compiler.rb b/lib/oga/xpath/compiler.rb index 7b35c6a..203f8a3 100644 --- a/lib/oga/xpath/compiler.rb +++ b/lib/oga/xpath/compiler.rb @@ -231,6 +231,19 @@ module Oga end end + # @param [AST::Node] ast + # @param [Oga::Ruby::Node] input + # @return [Oga::Ruby::Node] + def on_axis_descendant(ast, input, &block) + node = node_literal + + backup_variable(node, input) do + node.each_node.add_block(node) do + process(ast, node, &block).if_true { yield node } + end + end + end + # @param [AST::Node] ast # @param [Oga::Ruby::Node] input # @return [Oga::Ruby::Node]