Skip to content

Commit

Permalink
Draggable: Only apply ui-draggable-handle within the draggable instance
Browse files Browse the repository at this point in the history
Fixes #10212
Closes gh-1284
  • Loading branch information
tjvantoll committed Jul 15, 2014
1 parent 2447cab commit 7594a31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions tests/unit/draggable/draggable_core.js
Expand Up @@ -274,15 +274,19 @@ asyncTest( "#4261: active element should blur when mousing down on a draggable",
});

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

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

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

ok( !p.hasClass( "ui-draggable-handle" ),
"ensure handle class name is constrained within the draggble (#10212)" );

element.draggable( "destroy" );
ok( !element.find( "p" ).hasClass( "ui-draggable-handle" ), "removed in destroy()" );
});
Expand Down
4 changes: 3 additions & 1 deletion ui/draggable.js
Expand Up @@ -314,8 +314,10 @@ $.widget("ui.draggable", $.ui.mouse, {
},

_setHandleClassName: function() {
var handle = this.options.handle ?
this.element.find( this.options.handle ) : this.element;
this._removeHandleClassName();
$( this.options.handle || this.element ).addClass( "ui-draggable-handle" );
handle.addClass( "ui-draggable-handle" );
},

_removeHandleClassName: function() {
Expand Down

0 comments on commit 7594a31

Please sign in to comment.