From cdff72efed495d7a17c551578079619712758793 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Fri, 8 Mar 2013 10:08:46 -0500 Subject: [PATCH] Draggable: Account for descendants in handle. --- tests/unit/draggable/draggable.html | 2 +- tests/unit/draggable/draggable_options.js | 28 ++--------------------- ui/jquery.ui.draggable.js | 14 +++--------- 3 files changed, 6 insertions(+), 38 deletions(-) diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 6380f3e85..3d1d3326e 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -48,7 +48,7 @@
Relative
-
Absolute
+
Absolute
Absolute
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index 2e9f85c24..a71bf57cb 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -603,39 +603,15 @@ test( "grid, switching after initialization", function() { }); test( "{ handle: 'span' }", function() { - expect( 2 ); + expect( 3 ); var element = $( "#draggable2" ).draggable({ handle: "span" }); TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" ); + TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" ); TestHelpers.draggable.shouldNotMove( element, "drag element" ); }); -/* -test( "{ handle: Selectors }, matching parent selector", function() { - - expect( 4 ); - - var element = $( "#draggable2" ).draggable({ handle: "span a" }); - - $( "#qunit-fixture" ).append( "" ); - - element.find( "span" ).append( "" ); - - $( "#wrapping a" ).append( element ); - - TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) ); - - $( "#draggable2" ).draggable( "option", "handle", "span > a" ); - $( "#draggable2" ).find( "a" ).append( "" ); - - TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" ); - TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() ); - -}); -*/ - test( "handle, default, switching after initialization", function() { expect( 6 ); diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 56b8fc77d..5762d3171 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -281,17 +281,9 @@ $.widget("ui.draggable", $.ui.mouse, { }, _getHandle: function(event) { - - var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - - this.element.find( this.options.handle ).each(function() { - if(this === event.target) { - handle = true; - } - }); - - return handle; - + return this.options.handle ? + !!$( event.target ).closest( this.element.find( this.options.handle ) ).length : + true; }, _createHelper: function(event) { -- 2.39.5