From: Konstantin Dinev Date: Tue, 28 Feb 2017 16:21:46 +0000 (+0200) Subject: Resizable: Keep user-provided handles on destroy X-Git-Tag: 1.13.0-alpha.1~83 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c426b9a203271ab5e5e5f165a1d686c8281164bf;p=jquery-ui.git Resizable: Keep user-provided handles on destroy Closes gh-1798 Ref gh-1795 --- diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js index 4080bac0e..81206abf8 100644 --- a/tests/unit/resizable/options.js +++ b/tests/unit/resizable/options.js @@ -434,8 +434,10 @@ QUnit.test( "zIndex, applied to all handles", function( assert ) { } ); QUnit.test( "setOption handles", function( assert ) { - assert.expect( 15 ); + assert.expect( 19 ); + // https://bugs.jqueryui.com/ticket/3423 + // https://bugs.jqueryui.com/ticket/15084 var target = $( "
" ).resizable(), target2 = $( "
" + "
" + @@ -470,6 +472,12 @@ QUnit.test( "setOption handles", function( assert ) { target2.resizable( "option", "handles", "e, s, w" ); checkHandles( target2, [ "e", "s", "w" ] ); + + target.resizable( "destroy" ); + checkHandles( target, [ ] ); + + target2.resizable( "destroy" ); + checkHandles( target2, [ "e", "w" ] ); } ); QUnit.test( "alsoResize + containment", function( assert ) { diff --git a/ui/widgets/resizable.js b/ui/widgets/resizable.js index b5264ee53..36dd12514 100644 --- a/ui/widgets/resizable.js +++ b/ui/widgets/resizable.js @@ -187,15 +187,14 @@ $.widget( "ui.resizable", $.ui.mouse, { _destroy: function() { this._mouseDestroy(); + this._addedHandles.remove(); var wrapper, _destroy = function( exp ) { $( exp ) .removeData( "resizable" ) .removeData( "ui-resizable" ) - .off( ".resizable" ) - .find( ".ui-resizable-handle" ) - .remove(); + .off( ".resizable" ); }; // TODO: Unwrap at same DOM position