Browse Source

Support multiple views in removeChildren

pull/2524/head
Artur Arseniev 7 years ago
parent
commit
dcd80e679c
  1. 21
      src/dom_components/view/ComponentsView.js

21
src/dom_components/view/ComponentsView.js

@ -13,15 +13,17 @@ export default Backbone.View.extend({
}, },
removeChildren(removed, coll, opts = {}) { removeChildren(removed, coll, opts = {}) {
const em = this.config.em; const { em } = this.config;
const view = removed.view;
const tempComp = removed.opt.temporary;
const tempRemove = opts.temporary; const tempRemove = opts.temporary;
if (!view) return;
view.remove.apply(view); removed.views.forEach(view => {
const { childrenView, scriptContainer } = view; if (!view) return;
childrenView && childrenView.stopListening(); view.remove.apply(view);
scriptContainer && scriptContainer.remove(); const { childrenView, scriptContainer } = view;
childrenView && childrenView.stopListening();
scriptContainer && scriptContainer.remove();
});
removed.components().forEach(it => this.removeChildren(it, coll, opts)); removed.components().forEach(it => this.removeChildren(it, coll, opts));
if (em && !tempRemove) { if (em && !tempRemove) {
@ -31,6 +33,7 @@ export default Backbone.View.extend({
delete domc.componentsById[id]; delete domc.componentsById[id];
// Remove all related CSS rules // Remove all related CSS rules
// TODO: remove from the frame container
const allRules = em.get('CssComposer').getAll(); const allRules = em.get('CssComposer').getAll();
allRules.remove( allRules.remove(
allRules.filter( allRules.filter(
@ -38,7 +41,7 @@ export default Backbone.View.extend({
) )
); );
if (!tempComp) { if (!removed.opt.temporary) {
const cm = em.get('Commands'); const cm = em.get('Commands');
const hasSign = removed.get('style-signature'); const hasSign = removed.get('style-signature');
const optStyle = { target: removed }; const optStyle = { target: removed };

Loading…
Cancel
Save