Browse Source

Reset always collection on component clone

pull/803/head
Artur Arseniev 8 years ago
parent
commit
68dad021fd
  1. 12
      src/dom_components/model/Component.js

12
src/dom_components/model/Component.js

@ -601,10 +601,11 @@ const Component = Backbone.Model.extend(Styleable).extend(
* Override original clone method * Override original clone method
* @private * @private
*/ */
clone(reset) { clone() {
const em = this.em; const em = this.em;
const style = this.getStyle(); const style = this.getStyle();
const attr = { ...this.attributes }; const attr = { ...this.attributes };
const opts = { ...this.opt };
attr.attributes = { ...attr.attributes }; attr.attributes = { ...attr.attributes };
delete attr.attributes.id; delete attr.attributes.id;
attr.components = []; attr.components = [];
@ -612,7 +613,7 @@ const Component = Backbone.Model.extend(Styleable).extend(
attr.traits = []; attr.traits = [];
this.get('components').each((md, i) => { this.get('components').each((md, i) => {
attr.components[i] = md.clone(1); attr.components[i] = md.clone();
}); });
this.get('traits').each((md, i) => { this.get('traits').each((md, i) => {
attr.traits[i] = md.clone(); attr.traits[i] = md.clone();
@ -623,16 +624,13 @@ const Component = Backbone.Model.extend(Styleable).extend(
attr.status = ''; attr.status = '';
attr.view = ''; attr.view = '';
opts.collection = null;
if (reset) {
this.opt.collection = null;
}
if (em && em.getConfig('avoidInlineStyle') && !isEmpty(style)) { if (em && em.getConfig('avoidInlineStyle') && !isEmpty(style)) {
attr.style = style; attr.style = style;
} }
return new this.constructor(attr, this.opt); return new this.constructor(attr, opts);
}, },
/** /**

Loading…
Cancel
Save