]> source.dussan.org Git - jquery-ui.git/commitdiff
Draggable: Don't run stop methods for elements that have been removed. Fixed #8269...
authorTJ VanToll <tj.vantoll@gmail.com>
Mon, 30 Apr 2012 16:39:06 +0000 (12:39 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 30 Apr 2012 16:39:06 +0000 (12:39 -0400)
ui/jquery.ui.draggable.js

index 25b2567101204a58e01947b37890d2dbb54811e0..84077ed29b6205651c9b39b19125097d4516dea2 100644 (file)
@@ -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 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))) {