Raise for non node sets in the sum() function.
According to the XPath spec this function *can only* take node sets, nothing else. Lets actually enforce that.
This commit is contained in:
1 parent
ac06670c24
commit
7c68f2a49b
2 files changed
+10
No files matched your search
@@ -1174,6 +1174,10 @@ module Oga
|
||||
nodes = process(expression, context)
|
||||
sum = 0.0
|
||||
|
||||
unless nodes.is_a?(XML::NodeSet)
|
||||
raise TypeError, 'sum() can only operate on NodeSet instances'
|
||||
end
|
||||
|
||||
nodes.each do |node|
|
||||
sum += node.text.to_f
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user