Skip to content

Commit f0c3cf6

Browse files
committed
Draggable: Don't run stop methods for elements that have been removed. Fixed #8269 - Removing draggable element on drop : a(this).data("draggable") is undefined.
(cherry picked from commit 27d1023) Conflicts: ui/jquery.ui.draggable.js
1 parent 1ffafe6 commit f0c3cf6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ui/jquery.ui.draggable.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,14 @@ $.widget("ui.draggable", $.ui.mouse, {
208208
this.dropped = false;
209209
}
210210

211-
//if the original element is removed, don't bother to continue if helper is set to "original"
212-
if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original")
211+
//if the original element is no longer in the DOM don't bother to continue (see #8269)
212+
var element = this.element[0], elementInDom = false;
213+
while ( element && (element = element.parentNode) ) {
214+
if (element == document ) {
215+
elementInDom = true;
216+
}
217+
}
218+
if ( !elementInDom && this.options.helper === "original" )
213219
return false;
214220

215221
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {

0 commit comments

Comments
 (0)