diff --git a/src/dom_components/model/Components.js b/src/dom_components/model/Components.js index bc8e0cd4a..3d19490a3 100644 --- a/src/dom_components/model/Components.js +++ b/src/dom_components/model/Components.js @@ -84,18 +84,24 @@ export default Backbone.Collection.extend({ * Process component definition. */ processDef(mdl) { + // Avoid processing Models + if (mdl.cid && mdl.ccid) return mdl; const { em, config = {} } = this; const { processor } = config; - let model = { ...mdl }; // Avoid 'Cannot delete property ...' - - const modelPr = processor && processor(model); - if (modelPr) { - each(model, (val, key) => delete model[key]); - extend(model, modelPr); + let model = mdl; + + if (processor) { + model = { ...model }; // Avoid 'Cannot delete property ...' + const modelPr = processor(model); + if (modelPr) { + each(model, (val, key) => delete model[key]); + extend(model, modelPr); + } } // React JSX preset if (model.$$typeof && typeof model.props == 'object') { + model = { ...model }; model.props = { ...model.props }; const domc = em.get('DomComponents'); const parser = em.get('Parser'); diff --git a/test/specs/dom_components/model/Component.js b/test/specs/dom_components/model/Component.js index 29e2a5822..47e1919ea 100644 --- a/test/specs/dom_components/model/Component.js +++ b/test/specs/dom_components/model/Component.js @@ -330,6 +330,21 @@ module.exports = { expect(child.get('propagate')).toEqual(['removable']); }); + // This will try to avoid, eventually, issues with circular structures + test('Can stringify object after edits', () => { + const added = dcomp.addComponent(` +