diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 5cfb5351af0..80827d16a6a 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -40,7 +40,7 @@ test( "disabled", function(){ }); test( "max", function() { - expect( 2 ); + expect( 3 ); element = $( "
" ); options = { @@ -56,6 +56,16 @@ test( "max", function() { ok(element.slider( "value" ) === options.max, "value method is contained by max" ); element.slider( "destroy" ); + options = { + max: 99, + min: 1, + orientation: "horizontal", + step: 3, + value: 98.67854 + }; + + element.slider( options ); + ok(element.slider( "value" ) === options.max, "value method is contained by max" ); }); test( "min", function() { diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index e4f1cf7c941..12be55841cc 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -526,6 +526,9 @@ $.widget( "ui.slider", $.ui.mouse, { alignValue += ( valModStep > 0 ) ? step : ( -step ); } + if (alignValue > this._valueMax()){ + return this._valueMax(); + } // Since JavaScript has problems with large floats, round // the final value to 5 digits after the decimal point (see #4124) return parseFloat( alignValue.toFixed(5) );