Skip to content

Commit 7594a31

Browse files
committed
Draggable: Only apply ui-draggable-handle within the draggable instance
Fixes #10212 Closes jquerygh-1284
1 parent 2447cab commit 7594a31

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/unit/draggable/draggable_core.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,19 @@ asyncTest( "#4261: active element should blur when mousing down on a draggable",
274274
});
275275

276276
test( "ui-draggable-handle assigned to appropriate element", function() {
277-
expect( 4 );
277+
expect( 5 );
278278

279-
var element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
279+
var p = $( "<p>" ).appendTo( "#qunit-fixture" ),
280+
element = $( "<div><p></p></div>" ).appendTo( "#qunit-fixture" ).draggable();
280281
ok( element.hasClass( "ui-draggable-handle" ), "handle is element by default" );
281282

282283
element.draggable( "option", "handle", "p" );
283284
ok( !element.hasClass( "ui-draggable-handle" ), "removed from element" );
284285
ok( element.find( "p" ).hasClass( "ui-draggable-handle" ), "added to handle" );
285286

287+
ok( !p.hasClass( "ui-draggable-handle" ),
288+
"ensure handle class name is constrained within the draggble (#10212)" );
289+
286290
element.draggable( "destroy" );
287291
ok( !element.find( "p" ).hasClass( "ui-draggable-handle" ), "removed in destroy()" );
288292
});

ui/draggable.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ $.widget("ui.draggable", $.ui.mouse, {
314314
},
315315

316316
_setHandleClassName: function() {
317+
var handle = this.options.handle ?
318+
this.element.find( this.options.handle ) : this.element;
317319
this._removeHandleClassName();
318-
$( this.options.handle || this.element ).addClass( "ui-draggable-handle" );
320+
handle.addClass( "ui-draggable-handle" );
319321
},
320322

321323
_removeHandleClassName: function() {

0 commit comments

Comments
 (0)