aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.draggable.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2013-03-16 14:36:06 -0400
committerMike Sherov <mike.sherov@gmail.com>2013-03-16 14:36:06 -0400
commit9d8af804ad4cebe434d420b29467c596809a7cca (patch)
tree9a4f02ca087567b46380f3899c8a2d6216b0fcb1 /ui/jquery.ui.draggable.js
parentbd126a9c1cfcbc9d0fd370af25cfa0eab294fc4e (diff)
downloadjquery-ui-9d8af804ad4cebe434d420b29467c596809a7cca.tar.gz
jquery-ui-9d8af804ad4cebe434d420b29467c596809a7cca.zip
Draggable: make sure snap elements are in the document before snapping. Fixes #8459 - Draggable: element can snap to an element that was removed during drag.
Diffstat (limited to 'ui/jquery.ui.draggable.js')
-rw-r--r--ui/jquery.ui.draggable.js14
1 files changed, 3 insertions, 11 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 4c8a9d5d5..605425859 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -217,9 +217,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_mouseStop: function(event) {
//If we are using droppables, inform the manager about the drop
- var element,
- that = this,
- elementInDom = false,
+ var that = this,
dropped = false;
if ($.ui.ddmanager && !this.options.dropBehaviour) {
dropped = $.ui.ddmanager.drop(this, event);
@@ -232,13 +230,7 @@ $.widget("ui.draggable", $.ui.mouse, {
}
//if the original element is no longer in the DOM don't bother to continue (see #8269)
- element = this.element[0];
- while ( element && (element = element.parentNode) ) {
- if (element === document ) {
- elementInDom = true;
- }
- }
- if ( !elementInDom && this.options.helper === "original" ) {
+ if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
return false;
}
@@ -850,7 +842,7 @@ $.ui.plugin.add("draggable", "snap", {
t = inst.snapElements[i].top;
b = t + inst.snapElements[i].height;
- if(x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d) {
+ if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
if(inst.snapElements[i].snapping) {
(inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
}