diff options
author | Scott González <scott.gonzalez@gmail.com> | 2012-04-30 12:41:20 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2012-04-30 12:41:20 -0400 |
commit | f0c3cf6f1a623e7e6aa19c182b2b61c783a3bfc3 (patch) | |
tree | 9f43bb913afd75ca9953be62ee4c0af6e1e64ffa | |
parent | 1ffafe65b0dd2d8b0ae4dfcfe3beffb3123c7caf (diff) | |
download | jquery-ui-f0c3cf6f1a623e7e6aa19c182b2b61c783a3bfc3.tar.gz jquery-ui-f0c3cf6f1a623e7e6aa19c182b2b61c783a3bfc3.zip |
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 27d10235539e0f5baad6ee7e8d3d91cab65e2cfd)
Conflicts:
ui/jquery.ui.draggable.js
-rw-r--r-- | ui/jquery.ui.draggable.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index d294b2d22..32a753ead 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -208,8 +208,14 @@ $.widget("ui.draggable", $.ui.mouse, { this.dropped = false; } - //if the original element is removed, don't bother to continue if helper is set to "original" - if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original") + //if the original element is no longer in 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; + } + } + 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))) { |