diff --git a/src/dom_components/index.js b/src/dom_components/index.js index d92581bfc..f3466e258 100644 --- a/src/dom_components/index.js +++ b/src/dom_components/index.js @@ -344,12 +344,13 @@ export default () => { const handleChanges = this.handleChanges.bind(this); const handleRemoves = this.handleRemoves.bind(this); um.add(coll); - [[coll, 'add', handleChanges], [coll, 'remove', handleRemoves]].forEach( - els => { - em.stopListening(els[0], els[1], els[2]); - em.listenTo(els[0], els[1], els[2]); - } - ); + [ + [coll, 'add', handleChanges], + [coll, 'remove', handleRemoves] + ].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() { return componentsById; + }, + + destroy() { + this.clear(); + componentView.remove(); + [c, em, componentsById, component, componentView].forEach(i => (i = {})); } }; }; diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index fa9cdc0c0..5cd889028 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -766,7 +766,7 @@ export default Backbone.Model.extend({ DeviceManager } = this.attributes; this.stopDefault(); - DomComponents.clear(); + DomComponents.destroy(); CssComposer.destroy(); UndoManager.clear().removeAll(); Panels.getPanels().reset();