Handle boolean values in the boolean() function.

This commit is contained in:
Yorick Peterse committed 2014-08-28 09:36:21 +02:00
1 parent 8fb8fb17b6
commit 809ed9bfa6
2 files changed
+14 -3

No files matched your search

+6 -3
View File
@@ -1075,12 +1075,15 @@ module Oga
#
def on_call_boolean(context, expression)
retval = process(expression, context)
bool = false
if retval.is_a?(Numeric)
return !retval.nan? && !retval.zero?
else
return retval && !retval.empty?
bool = !retval.nan? && !retval.zero?
elsif retval
bool = !retval.respond_to?(:empty?) || !retval.empty?
end
return bool
end
##