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:
parent
8884db8cb6
commit
6eacf74da4
|
@ -724,11 +724,11 @@ module Oga
|
||||||
right = process(ast_node.children[1], context)
|
right = process(ast_node.children[1], context)
|
||||||
|
|
||||||
if left.is_a?(XML::NodeSet)
|
if left.is_a?(XML::NodeSet)
|
||||||
left = left.text
|
left = first_node_text(left)
|
||||||
end
|
end
|
||||||
|
|
||||||
if right.is_a?(XML::NodeSet)
|
if right.is_a?(XML::NodeSet)
|
||||||
right = right.text
|
right = first_node_text(right)
|
||||||
end
|
end
|
||||||
|
|
||||||
if left.is_a?(Numeric) and !right.is_a?(Numeric)
|
if left.is_a?(Numeric) and !right.is_a?(Numeric)
|
||||||
|
|
|
@ -46,5 +46,13 @@ describe Oga::XPath::Evaluator do
|
||||||
example 'return true if a node set and a string are equal' do
|
example 'return true if a node set and a string are equal' do
|
||||||
@evaluator.evaluate('root/a = "10"').should == true
|
@evaluator.evaluate('root/a = "10"').should == true
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue