]> source.dussan.org Git - jquery-ui.git/commitdiff
Slider: Remove range div when changing range option to false. Fixes #9355 - Slider...
authorScott González <scott.gonzalez@gmail.com>
Mon, 3 Jun 2013 19:14:08 +0000 (15:14 -0400)
committerScott González <scott.gonzalez@gmail.com>
Tue, 26 Nov 2013 15:42:09 +0000 (10:42 -0500)
(cherry picked from commit 2ba75e2c93638d89e89de52347da0013a7a841b8)

tests/unit/slider/slider_options.js
ui/jquery.ui.slider.js

index f46dbde99acf86f3a60e36f297e8c55f976c42cc..d4403d1aff1755a5a1425a41330e964a319d0056 100644 (file)
@@ -200,7 +200,7 @@ test( "values", function() {
 });
 
 test( "range", function() {
-       expect( 27 );
+       expect( 33 );
        var range;
 
        // min
@@ -300,6 +300,21 @@ test( "range", function() {
        equal( element.slider( "option", "values" ), null, "values" );
        deepEqual( element.slider( "values" ), [] , "values" );
        element.slider( "destroy" );
+
+       // Change range from true to false
+       element = $( "<div></div>" ).slider({
+               range: true,
+               min: 1,
+               max: 10,
+               step: 1
+       }).slider( "option", "range", false );
+       equal( element.find( ".ui-slider-handle" ).length, 2, "range switch from true to false, both handles remain" );
+       equal( element.find( ".ui-slider-range" ).length, 0, "range switch from true to false" );
+       equal( element.slider( "option", "value" ), 0 , "option value" );
+       equal( element.slider( "value" ), 1 , "value" );
+       deepEqual( element.slider( "option", "values" ), [1, 1], "option values" );
+       deepEqual( element.slider( "values" ), [1, 1], "values" );
+       element.slider( "destroy" );
 });
 
 })( jQuery );
index 9338559b4c136d8ec7ee491bc4e2d10873434175..7d4fb36d1dfa8d119a3a9e37c8725459772d3368 100644 (file)
@@ -131,7 +131,10 @@ $.widget( "ui.slider", $.ui.mouse, {
                        this.range.addClass( classes +
                                ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
                } else {
-                       this.range = $([]);
+                       if ( this.range ) {
+                               this.range.remove();
+                       }
+                       this.range = null;
                }
        },
 
@@ -145,7 +148,9 @@ $.widget( "ui.slider", $.ui.mouse, {
 
        _destroy: function() {
                this.handles.remove();
-               this.range.remove();
+               if ( this.range ) {
+                       this.range.remove();
+               }
 
                this.element
                        .removeClass( "ui-slider" +