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:
Yorick Peterse committed 2014-08-27 23:47:19 +02:00
1 parent ac06670c24
commit 7c68f2a49b
2 files changed
+10

No files matched your search

+4
View File
@@ -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