From e12e3e12b19e226b90e4a0ec3848e400a80c8267 Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Tue, 19 Aug 2014 15:09:28 -0400 Subject: [PATCH] Mouse: Only detect out of document mouseups after a mousemove This prevents the firing of mouseup in the case of IE<9, which will fire a mousemove event if content is placed under the cursor on mousedown. Fixes #7778 --- tests/jquery.simulate.js | 2 +- tests/unit/draggable/draggable_core.js | 17 ++++++++++++ tests/visual/draggable/replaced.html | 38 ++++++++++++++++++++++++++ tests/visual/index.html | 5 ++++ ui/mouse.js | 24 ++++++++++++---- 5 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 tests/visual/draggable/replaced.html diff --git a/tests/jquery.simulate.js b/tests/jquery.simulate.js index 1dd96ac3a..28e8a103b 100644 --- a/tests/jquery.simulate.js +++ b/tests/jquery.simulate.js @@ -144,7 +144,7 @@ $.extend( $.simulate.prototype, { 0: 1, 1: 4, 2: 2 - }[ event.button ] || event.button; + }[ event.button ] || ( event.button === -1 ? 0 : event.button ); } return event; diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 8bc48f14c..4ea5e608a 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -111,6 +111,23 @@ test( "#8269: Removing draggable element on drop", function() { } }); +// http://bugs.jqueryui.com/ticket/7778 +// drag element breaks in IE8 when its content is replaced onmousedown +test( "Stray mousemove after mousedown still drags", function() { + expect( 2 ); + + var element = $( "#draggable1" ).draggable({ scroll: false }); + + // In IE8, when content is placed under the mouse (e.g. when draggable content is replaced + // on mousedown), mousemove is triggered on those elements even though the mouse hasn't moved. + // Support: IE <9 + element.bind( "mousedown", function() { + $( document ).simulate( "mousemove", { button: -1 }); + }); + + TestHelpers.draggable.shouldMove( element, "element is draggable" ); +}); + test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() { expect( 2 ); diff --git a/tests/visual/draggable/replaced.html b/tests/visual/draggable/replaced.html new file mode 100644 index 000000000..9b5471694 --- /dev/null +++ b/tests/visual/draggable/replaced.html @@ -0,0 +1,38 @@ + + + + + Draggable Visual Test + + + + + + + + + + + + +

WHAT: A draggable, whose content is replaced onmousedown.

+

EXPECTED: In IE8, the draggable can actually be dragged.

+ +
content
+ + + diff --git a/tests/visual/index.html b/tests/visual/index.html index 949fb7e82..736ba3117 100644 --- a/tests/visual/index.html +++ b/tests/visual/index.html @@ -40,6 +40,11 @@
  • Overlapping dialogs
  • +

    Draggable

    + +

    Effects