diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index c5c7e1254aa..b4ceedc595d 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -62,7 +62,7 @@ test( "disable", function() { }); test( "value", function() { - expect( 17 ); + expect( 18 ); $( [ false, "min", "max" ] ).each(function() { var element = $( "
" ).slider({ range: this, @@ -88,6 +88,17 @@ test( "value", function() { equal( element.slider( "value" ), 1, "value method get respects max" ); equal( element.slider( "value", 2 ), element, "value method is chainable" ); equal( element.slider( "option", "value" ), 1, "value method set respects max" ); + + element = $("").slider({ + min:2, + value: 2, + max: 2.4, + step: 0.01 + }); + + //set max value with step 0.01 + element.slider("option", "value", 2.4); + equal(element.slider("value"), 2.4, "value is set to max with 0.01 step"); }); //test( "values", function() { diff --git a/ui/slider.js b/ui/slider.js index 4af7dc34fde..fceb367f31c 100644 --- a/ui/slider.js +++ b/ui/slider.js @@ -558,7 +558,7 @@ return $.widget( "ui.slider", $.ui.mouse, { var max = this.options.max, min = this._valueMin(), step = this.options.step, - aboveMin = Math.floor( ( max - min ) / step ) * step; + aboveMin = Math.floor( ( +( max - min ).toFixed( this._precision() ) ) / step ) * step; max = aboveMin + min; this.max = parseFloat( max.toFixed( this._precision() ) ); },