Fix floating point comparision issue. Closes GH-341.

This commit is contained in:
Chris Eppstein 2011-04-17 11:36:39 -07:00
parent 810b95e7f3
commit 3921e6f856

View File

@ -290,7 +290,7 @@ module Compass::SassExtensions::Functions::GradientSupport
stop = pos.stop stop = pos.stop
stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"] stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
# Make sure the color stops are specified in the right order. # Make sure the color stops are specified in the right order.
if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && BigDecimal.new(stop.value.to_s) < BigDecimal.new(last_value.value.to_s) if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && (stop.value * 1000).round < (last_value.value * 1000).round
raise Sass::SyntaxError.new("Color stops must be specified in increasing order. #{stop.value} came after #{last_value.value}.") raise Sass::SyntaxError.new("Color stops must be specified in increasing order. #{stop.value} came after #{last_value.value}.")
end end
last_value = stop last_value = stop