Fixed ancestor-or-self relative to attributes

Per libxml behaviour this axis shouldn't match attributes when using
"ancestor-or-self::*".
This commit is contained in:
Yorick Peterse 2015-08-27 10:49:32 +02:00
parent d5aad9c1c9
commit 70bea2071c
2 changed files with 7 additions and 1 deletions

View File

@ -176,7 +176,7 @@ module Oga
def on_axis_ancestor_or_self(ast, input)
parent = unique_literal(:parent)
process(ast, input)
process(ast, input).and(input.is_a?(XML::Node))
.if_true { yield input }
.followed_by do
attribute_or_node(input).if_true do

View File

@ -23,6 +23,12 @@ describe Oga::XPath::Compiler do
evaluate_xpath(@a1.attribute('foo')).should == node_set(@a1)
end
end
describe 'ancestor-or-self::foo' do
it 'returns an empty NodeSet' do
evaluate_xpath(@a1.attribute('foo')).should == node_set
end
end
end
describe 'relative to an element' do