Fixed comparing node equality in XPath expressions

Previously this would take the text of the entire node set, not of the first
node in the set.
This commit is contained in:
Yorick Peterse 2014-09-01 22:34:18 +02:00
parent 8884db8cb6
commit 6eacf74da4
2 changed files with 10 additions and 2 deletions

View File

@ -724,11 +724,11 @@ module Oga
right = process(ast_node.children[1], context)
if left.is_a?(XML::NodeSet)
left = left.text
left = first_node_text(left)
end
if right.is_a?(XML::NodeSet)
right = right.text
right = first_node_text(right)
end
if left.is_a?(Numeric) and !right.is_a?(Numeric)

View File

@ -46,5 +46,13 @@ describe Oga::XPath::Evaluator do
example 'return true if a node set and a string are equal' do
@evaluator.evaluate('root/a = "10"').should == true
end
example 'return true if a node set wildcard and a number are equal' do
@evaluator.evaluate('root/* = 10').should == true
end
example 'return true if a number and a node set wildcard are equal' do
@evaluator.evaluate('10 = root/*').should == true
end
end
end