From c6709faf526f03cc56eb2d7640dfbb6d91795ea8 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Tue, 12 Aug 2014 23:34:08 +0300 Subject: [PATCH] fix(sortable): clear savedNodes to fix a leak for items that get removed --- src/sortable.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/sortable.js b/src/sortable.js index d293eb8..a18f046 100644 --- a/src/sortable.js +++ b/src/sortable.js @@ -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 @@ -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) {