Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Draggable: Don't run stop methods for elements that have been removed…
…. Fixed #8269
  • Loading branch information
tjvantoll committed Apr 25, 2012
commit 58ed56e53e21c95ad2294c760cbb2b10110a1ab1
10 changes: 8 additions & 2 deletions ui/jquery.ui.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,14 @@ $.widget("ui.draggable", $.ui.mouse, {
this.dropped = false;
}

//if the original element is removed, don't bother to continue
if((!this.element[0] || !this.element[0].parentNode) && this.options.helper === "original")
//if the original element is no longer on the DOM don't bother to continue (see #8269)
var element = this.element[0], elementInDom = false;
while ( element && (element = element.parentNode) ) {
if (element == document ) {
elementInDom = true;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should a break; be added?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nowhere else to go. The only extra overhead is checking if element.parentNode exists.

}
}
if ( !elementInDom && this.options.helper === "original" )
return false;

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))) {
Expand Down