Skip to content

Commit 278d1e1

Browse files
kdinevscottgonzalez
authored andcommitted
Resizable: Keep user defined handles on _setOption
Fixes #15084 Closes gh-1795
1 parent a3b9129 commit 278d1e1

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

tests/unit/resizable/options.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,20 @@ QUnit.test( "zIndex, applied to all handles", function( assert ) {
434434
} );
435435

436436
QUnit.test( "setOption handles", function( assert ) {
437-
assert.expect( 11 );
438-
439-
var target = $( "<div></div>" ).resizable();
440-
441-
function checkHandles( expectedHandles ) {
437+
assert.expect( 15 );
438+
439+
var target = $( "<div></div>" ).resizable(),
440+
target2 = $( "<div>" +
441+
"<div class='ui-resizable-handle ui-resizable-e'></div>" +
442+
"<div class='ui-resizable-handle ui-resizable-w'></div>" +
443+
"</div>" ).resizable( {
444+
handles: {
445+
"e": "ui-resizable-e",
446+
"w": "ui-resizable-w"
447+
}
448+
} );
449+
450+
function checkHandles( target, expectedHandles ) {
442451
expectedHandles = $.map( expectedHandles, function( value ) {
443452
return ".ui-resizable-" + value;
444453
} );
@@ -451,13 +460,16 @@ QUnit.test( "setOption handles", function( assert ) {
451460
} );
452461
}
453462

454-
checkHandles( [ "e", "s", "se" ] );
463+
checkHandles( target, [ "e", "s", "se" ] );
455464

456465
target.resizable( "option", "handles", "n, w, nw" );
457-
checkHandles( [ "n", "w", "nw" ] );
466+
checkHandles( target, [ "n", "w", "nw" ] );
458467

459468
target.resizable( "option", "handles", "s, w" );
460-
checkHandles( [ "s", "w" ] );
469+
checkHandles( target, [ "s", "w" ] );
470+
471+
target2.resizable( "option", "handles", "e, s, w" );
472+
checkHandles( target2, [ "e", "s", "w" ] );
461473
} );
462474

463475
QUnit.test( "alsoResize + containment", function( assert ) {

ui/widgets/resizable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
250250
} );
251251

252252
this._handles = $();
253+
this._addedHandles = $();
253254
if ( this.handles.constructor === String ) {
254255

255256
if ( this.handles === "all" ) {
@@ -269,7 +270,10 @@ $.widget( "ui.resizable", $.ui.mouse, {
269270
axis.css( { zIndex: o.zIndex } );
270271

271272
this.handles[ handle ] = ".ui-resizable-" + handle;
272-
this.element.append( axis );
273+
if ( !this.element.children( this.handles[ handle ] ).length ) {
274+
this.element.append( axis );
275+
this._addedHandles = this._addedHandles.add( axis );
276+
}
273277
}
274278

275279
}
@@ -335,7 +339,7 @@ $.widget( "ui.resizable", $.ui.mouse, {
335339
},
336340

337341
_removeHandles: function() {
338-
this._handles.remove();
342+
this._addedHandles.remove();
339343
},
340344

341345
_mouseCapture: function( event ) {

0 commit comments

Comments
 (0)