Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

fix(sortable): clear savedNodes to fix a leak when items get removed #244

Merged
merged 1 commit into from
Aug 12, 2014
Merged
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
12 changes: 12 additions & 0 deletions src/sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ angular.module('ui.sortable', [])
}
savedNodes.appendTo(element);

// If this is the target connected list then
// it's safe to clear the restored nodes since:
// update is currently running and
// stop is not called for the target list.
if(ui.item.sortable.received) {
savedNodes = null;
}

// If received is true (an item was dropped in from another list)
// then we add the new item to this list otherwise wait until the
// stop event where we will know if it was a sort or item was
Expand Down Expand Up @@ -173,6 +181,10 @@ angular.module('ui.sortable', [])
savedNodes.appendTo(element);
}
}

// It's now safe to clear the savedNodes
// since stop is the last callback.
savedNodes = null;
};

callbacks.receive = function(e, ui) {
Expand Down