From e2555e7b0dcfb5ca0f6d3fd165b2c2e5fa9c3449 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 24 Apr 2018 22:50:58 +0200 Subject: [PATCH] Autoremove list elements --- UI/ActionManager.js | 10 +++++----- UI/UIManager.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/UI/ActionManager.js b/UI/ActionManager.js index 2c289fb..7f122e2 100644 --- a/UI/ActionManager.js +++ b/UI/ActionManager.js @@ -91,11 +91,11 @@ const observeConfig = { childList: false, attributes: true, subtree: false }; if (hasSelector) { - this.app.eventManager.attach(e.id + 'childList', function(data) { + this.app.eventManager.attach(e.id + '-childList', function(data) { const length = data.addedNodes.length; for (let j = 0; j < length; ++j) { - self.bindListener(data.addedNodes[j].id, listeners[i]); + self.bindListener(data.addedNodes[j].id, listeners[i], true); } }); @@ -103,7 +103,7 @@ observeConfig.subtree = true; } - this.app.eventManager.attach(e.id + 'attributes', function(data) {}); + this.app.eventManager.attach(e.id + '-attributes', function(data) {}); this.app.uiManager.getDOMObserver().observe(e, observeConfig); } }; @@ -120,7 +120,7 @@ * * @since 1.0.0 */ - jsOMS.UI.ActionManager.prototype.bindListener = function(id, listener) + jsOMS.UI.ActionManager.prototype.bindListener = function(id, listener, removable = false) { const self = this, actionLength = listener.action.length; @@ -133,7 +133,7 @@ this.app.eventManager.attach(id + '-' + listener.key + '-' + listener.action[j - 1].key, function (data) { self.runAction(id, listener, listener.action[j], data); - }, false, true); + }, removable, true); // todo: make actions removable e.g. in case of child elements getting removed = tag list } // todo: the true here is a memory leak since it should be removed at some point?! // todo: handle onload action right after registering everything. this will be used for onload api calls in order to get content such as lists or models. Maybe in the main application after registering a invoke('onload') should be called if the application wants to execute the onload elements diff --git a/UI/UIManager.js b/UI/UIManager.js index 01dc4dc..bfff542 100644 --- a/UI/UIManager.js +++ b/UI/UIManager.js @@ -36,7 +36,7 @@ const length = mutations.length; for(let i = 0; i < length; i++) { - self.app.eventManager.trigger(mutations[i].target.id + mutations[i].type, 0, mutations[i]); + self.app.eventManager.trigger(mutations[i].target.id + '-' + mutations[i].type, 0, mutations[i]); } }); };