move destroy responsibility to blockObject

This commit is contained in:
Niels Lyngsø
2020-06-23 20:42:14 +02:00
parent bf12009b40
commit 67a9a3f807
@@ -643,6 +643,19 @@
addWatchers(blockObject, this.isolatedScope);
addWatchers(blockObject, this.isolatedScope, true);
blockObject.destroy = function() {
// remove property value watchers:
this.__watchers.forEach(w => { w(); });
// help carbage collector:
delete this.layout;
delete this.data;
// remove model from isolatedScope.
delete this.__scope.blockObjects["_" + this.key];
delete this.__scope;
}
return blockObject;
},
@@ -669,15 +682,7 @@
*/
destroyBlockObject: function(blockObject) {
// remove property value watchers:
blockObject.__watchers.forEach(w => { w(); });
// help carbage collector:
delete blockObject.layout;
delete blockObject.data;
// remove model from isolatedScope.
delete this.isolatedScope.blockObjects["_" + blockObject.key];
blockObject.destroy();
},