Merge pull request #746 from gregdking/next

#745 Remove references to DOM nodes when unmounting (Follow-up to #727)
This commit is contained in:
Leo Horie 2015-08-04 14:51:55 -04:00
commit fe65aa748c

View file

@ -782,6 +782,8 @@ var m = (function app(window, undefined) {
controllers[index].onunload(event); controllers[index].onunload(event);
} }
var isNullComponent = component === null;
if (!isPrevented) { if (!isPrevented) {
m.redraw.strategy("all"); m.redraw.strategy("all");
m.startComputation(); m.startComputation();
@ -795,14 +797,24 @@ var m = (function app(window, undefined) {
components[index] = component; components[index] = component;
} }
endFirstComputation(); endFirstComputation();
if (isNullComponent) {
removeRootElement(root, index);
}
return controllers[index]; return controllers[index];
} }
if (!component) { if (isNullComponent) {
roots.splice(index, 1); removeRootElement(root, index);
controllers.splice(index, 1);
components.splice(index, 1);
} }
}; };
function removeRootElement(root, index) {
roots.splice(index, 1);
controllers.splice(index, 1);
components.splice(index, 1);
reset(root);
nodeCache.splice(getCellCacheKey(root), 1);
}
var redrawing = false, forcing = false; var redrawing = false, forcing = false;
m.redraw = function(force) { m.redraw = function(force) {
if (redrawing) return; if (redrawing) return;