Browse Source

Add destroy method to DomComponents module

pull/3147/head
Artur Arseniev 6 years ago
parent
commit
a0fbe75391
  1. 19
      src/dom_components/index.js
  2. 2
      src/editor/model/Editor.js

19
src/dom_components/index.js

@ -344,12 +344,13 @@ export default () => {
const handleChanges = this.handleChanges.bind(this); const handleChanges = this.handleChanges.bind(this);
const handleRemoves = this.handleRemoves.bind(this); const handleRemoves = this.handleRemoves.bind(this);
um.add(coll); um.add(coll);
[[coll, 'add', handleChanges], [coll, 'remove', handleRemoves]].forEach( [
els => { [coll, 'add', handleChanges],
em.stopListening(els[0], els[1], els[2]); [coll, 'remove', handleRemoves]
em.listenTo(els[0], els[1], els[2]); ].forEach(els => {
} em.stopListening(els[0], els[1], els[2]);
); em.listenTo(els[0], els[1], els[2]);
});
} }
}, },
@ -733,6 +734,12 @@ export default () => {
allById() { allById() {
return componentsById; return componentsById;
},
destroy() {
this.clear();
componentView.remove();
[c, em, componentsById, component, componentView].forEach(i => (i = {}));
} }
}; };
}; };

2
src/editor/model/Editor.js

@ -766,7 +766,7 @@ export default Backbone.Model.extend({
DeviceManager DeviceManager
} = this.attributes; } = this.attributes;
this.stopDefault(); this.stopDefault();
DomComponents.clear(); DomComponents.destroy();
CssComposer.destroy(); CssComposer.destroy();
UndoManager.clear().removeAll(); UndoManager.clear().removeAll();
Panels.getPanels().reset(); Panels.getPanels().reset();

Loading…
Cancel
Save