Skip to content

Commit 77a4aaf

Browse files
zhizhangchenscottgonzalez
authored andcommitted
Sortable: Fix a bug of removing an item while iterating an array. Fixes #8571 - Out of range problem in when dragging a nested sortable.
1 parent a3f1a34 commit 77a4aaf

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

ui/jquery.ui.sortable.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,14 +562,13 @@ $.widget("ui.sortable", $.ui.mouse, {
562562

563563
var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
564564

565-
for (var i=0; i < this.items.length; i++) {
566-
565+
this.items = $.grep(this.items, function (item) {
567566
for (var j=0; j < list.length; j++) {
568-
if(list[j] == this.items[i].item[0])
569-
this.items.splice(i,1);
567+
if(list[j] == item.item[0])
568+
return false;
570569
};
571-
572-
};
570+
return true;
571+
});
573572

574573
},
575574

0 commit comments

Comments
 (0)