Basic support for the XPath "parent" axis.
The usage of `parent::node()` is not yet supported.
This commit is contained in:
1 parent
c0a6610d65
commit
375f3d7870
2 files changed
+63
No files matched your search
@@ -307,6 +307,27 @@ module Oga
|
||||
return nodes
|
||||
end
|
||||
|
||||
##
|
||||
# Evaluates the `parent` axis.
|
||||
#
|
||||
# @param [Oga::XPath::Node] ast_node
|
||||
# @param [Oga::XML::NodeSet] context
|
||||
# @return [Oga::XML::NodeSet]
|
||||
#
|
||||
def on_axis_parent(ast_node, context)
|
||||
nodes = XML::NodeSet.new
|
||||
|
||||
context.each do |context_node|
|
||||
next unless has_parent?(context_node)
|
||||
|
||||
parent = context_node.parent
|
||||
|
||||
nodes << parent if node_matches?(parent, ast_node)
|
||||
end
|
||||
|
||||
return nodes
|
||||
end
|
||||
|
||||
##
|
||||
# Returns a node set containing all the child nodes of the given set of
|
||||
# nodes.
|
||||
|
||||
Reference in new issue
Block a user