From 0bff32a2b1c2273e46dc0f70bc1058ad304ebcc5 Mon Sep 17 00:00:00 2001 From: Mathias Stenbom Date: Fri, 2 Nov 2012 09:59:46 +0100 Subject: [PATCH] Resizable: Made handles work with complex markup. Fixes #8756 - Resizable: Complex markup for handles. --- tests/unit/resizable/resizable_core.js | 20 ++++++++++++++++++++ ui/jquery.ui.resizable.js | 9 +++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/tests/unit/resizable/resizable_core.js b/tests/unit/resizable/resizable_core.js index 01f15bd4b..a1ac22272 100644 --- a/tests/unit/resizable/resizable_core.js +++ b/tests/unit/resizable/resizable_core.js @@ -129,4 +129,24 @@ test("nw", function() { equal( target.height(), 100, "compare height" ); }); +test("handle with complex markup (#8756)", function() { + expect(2); + + $('#resizable1') + .append( + $('
') + .addClass("ui-resizable-handle") + .addClass("ui-resizable-w") + .append($('
')) + ); + + var handle = '.ui-resizable-w div', target = $('#resizable1').resizable({ handles: 'all' }); + + TestHelpers.resizable.drag(handle, -50); + equal( target.width(), 150, "compare width" ); + + TestHelpers.resizable.drag(handle, 50); + equal( target.width(), 100, "compare width" ); +}); + })(jQuery); diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 13f6c71d0..c2ad28716 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -231,14 +231,15 @@ $.widget("ui.resizable", $.ui.mouse, { }, _mouseCapture: function(event) { - var handle = false; + var capture = false; for (var i in this.handles) { - if ($(this.handles[i])[0] == event.target) { - handle = true; + var handle = $(this.handles[i])[0]; + if (handle == event.target || $.contains(handle, event.target)) { + capture = true; } } - return !this.options.disabled && handle; + return !this.options.disabled && capture; }, _mouseStart: function(event) { -- 2.39.5