Updated XPath evaluator for the new AST.

This is still a bit of a hack. Then again, it already was a hack to begin with.
This commit is contained in:
Yorick Peterse 2014-07-12 00:18:32 +02:00
parent be4f4ad744
commit 5808ffa7a4
1 changed files with 8 additions and 8 deletions

View File

@ -45,23 +45,23 @@ module Oga
end end
end end
def on_absolute(node) def on_absolute_path(node)
if @document.respond_to?(:root_node) if @document.respond_to?(:root_node)
@context = XML::NodeSet.new([@document.root_node]) @context = XML::NodeSet.new([@document.root_node])
end end
process_all(node.children) on_path(node)
end end
def on_path(node) def on_path(node)
test, children = *node last_index = node.children.length - 1
process(test) node.children.each_with_index do |test, index|
process(test)
if children and !@stack.empty? if index < last_index and !@stack.empty?
swap_context swap_context
end
process(children)
end end
end end