From 2ffcf02de361262e9496719016619c520745e90d Mon Sep 17 00:00:00 2001 From: Paul Bakaus Date: Tue, 17 Feb 2009 13:01:19 +0000 Subject: [PATCH] slider: limit the returned floats to 5 digits after the decimal point, corrects JS float errors (fixes #4124 - Value should always be constrained to valid step values) --- ui/ui.slider.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/ui.slider.js b/ui/ui.slider.js index 91f257157..2b388c6d5 100644 --- a/ui/ui.slider.js +++ b/ui/ui.slider.js @@ -287,7 +287,9 @@ $.widget("ui.slider", $.extend({}, $.ui.mouse, { if (valueMouseModStep > (this.options.step / 2)) normValue += this.options.step; - return normValue; + // Since JavaScript has problems with large floats, round + // the final value to 5 digits after the decimal point (see #4124) + return parseFloat(normValue.toFixed(5)); },