From dcd80e679c26b7f3932e87d306dcd761d88915b6 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 26 Sep 2019 08:38:33 +0200 Subject: [PATCH] Support multiple views in removeChildren --- src/dom_components/view/ComponentsView.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/dom_components/view/ComponentsView.js b/src/dom_components/view/ComponentsView.js index d57b03386..5f22a1ba5 100644 --- a/src/dom_components/view/ComponentsView.js +++ b/src/dom_components/view/ComponentsView.js @@ -13,15 +13,17 @@ export default Backbone.View.extend({ }, removeChildren(removed, coll, opts = {}) { - const em = this.config.em; - const view = removed.view; - const tempComp = removed.opt.temporary; + const { em } = this.config; const tempRemove = opts.temporary; - if (!view) return; - view.remove.apply(view); - const { childrenView, scriptContainer } = view; - childrenView && childrenView.stopListening(); - scriptContainer && scriptContainer.remove(); + + removed.views.forEach(view => { + if (!view) return; + view.remove.apply(view); + const { childrenView, scriptContainer } = view; + childrenView && childrenView.stopListening(); + scriptContainer && scriptContainer.remove(); + }); + removed.components().forEach(it => this.removeChildren(it, coll, opts)); if (em && !tempRemove) { @@ -31,6 +33,7 @@ export default Backbone.View.extend({ delete domc.componentsById[id]; // Remove all related CSS rules + // TODO: remove from the frame container const allRules = em.get('CssComposer').getAll(); allRules.remove( allRules.filter( @@ -38,7 +41,7 @@ export default Backbone.View.extend({ ) ); - if (!tempComp) { + if (!removed.opt.temporary) { const cm = em.get('Commands'); const hasSign = removed.get('style-signature'); const optStyle = { target: removed };