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

Commit a02888e

Browse files
committed
Merge pull request #244 from thgreasi/clearSavedNodes
fix(sortable): clear savedNodes to fix a leak when items get removed
2 parents 19dfc6c + c6709fa commit a02888e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/sortable.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ angular.module('ui.sortable', [])
140140
}
141141
savedNodes.appendTo(element);
142142

143+
// If this is the target connected list then
144+
// it's safe to clear the restored nodes since:
145+
// update is currently running and
146+
// stop is not called for the target list.
147+
if(ui.item.sortable.received) {
148+
savedNodes = null;
149+
}
150+
143151
// If received is true (an item was dropped in from another list)
144152
// then we add the new item to this list otherwise wait until the
145153
// stop event where we will know if it was a sort or item was
@@ -173,6 +181,10 @@ angular.module('ui.sortable', [])
173181
savedNodes.appendTo(element);
174182
}
175183
}
184+
185+
// It's now safe to clear the savedNodes
186+
// since stop is the last callback.
187+
savedNodes = null;
176188
};
177189

178190
callbacks.receive = function(e, ui) {

0 commit comments

Comments
 (0)