Browse Source

On clone of symbol, return the instance

symbols-2
Artur Arseniev 5 years ago
parent
commit
2eb420aefd
  1. 38
      src/dom_components/model/Component.js

38
src/dom_components/model/Component.js

@ -684,14 +684,11 @@ const Component = Backbone.Model.extend(Styleable).extend(
const addedInstances = m.__getSymbToUp(toUpOpts); const addedInstances = m.__getSymbToUp(toUpOpts);
!m.opt.temporary && !m.opt.temporary &&
console.log( console.log(
'Added cid', `Added cid ${m.cid} (symb: ${m.__isSymbol()}) in ${
this.cid, this.cid
m.toHTML(), } (symb: ${this.__isSymbol()})`,
o, 'SymbToUp added',
'toUp',
addedInstances, addedInstances,
'isSymb',
this.__isSymbol(),
'symbToUp', 'symbToUp',
this.__getSymbToUp(toUpOpts), this.__getSymbToUp(toUpOpts),
{ toUpOpts } { toUpOpts }
@ -705,7 +702,6 @@ const Component = Backbone.Model.extend(Styleable).extend(
return symbTop && addedTop && addedTop === symbTop; return symbTop && addedTop && addedTop === symbTop;
})[0]; })[0];
const toAppend = symbPrev || m.clone({ symbol: 1 }); const toAppend = symbPrev || m.clone({ symbol: 1 });
// If this is the instance which triggered the main update // If this is the instance which triggered the main update
// I have to realign it as other instances // I have to realign it as other instances
// if (fromInstance === symb) { // if (fromInstance === symb) {
@ -718,11 +714,15 @@ const Component = Backbone.Model.extend(Styleable).extend(
// !m.opt.temporary && console.log('Exit, fromInstance === symb', fromInstance, 'toAppend', appended, symbMain.get('__symbol')) // !m.opt.temporary && console.log('Exit, fromInstance === symb', fromInstance, 'toAppend', appended, symbMain.get('__symbol'))
// return; // return;
// } // }
console.log('Added inner', toAppend.cid, toAppend.toHTML(), { !m.opt.temporary &&
symb, console.log(
symbPrev, 'Added inner',
toAppend toAppend.cid,
}); 'of',
symb.cid,
`(symb ${symb.__isSymbol()})`,
{ symb, symbPrev, toAppend }
);
symb.append(toAppend, { fromInstance: this, toAppend: m, ...o }); symb.append(toAppend, { fromInstance: this, toAppend: m, ...o });
}); });
} else { } else {
@ -1114,9 +1114,15 @@ const Component = Backbone.Model.extend(Styleable).extend(
symbol.get(keySymbols).push(cloned); symbol.get(keySymbols).push(cloned);
cloned.__initSymb(); cloned.__initSymb();
} else if (opt.symbol) { } else if (opt.symbol) {
cloned.set(keySymbols, [this]); if (this.__isSymbol()) {
[this, cloned].map(i => i.__initSymb()); this.get(keySymbols).push(cloned);
this.set(keySymbol, cloned); cloned.set(keySymbol, this);
cloned.__initSymb();
} else {
cloned.set(keySymbols, [this]);
[this, cloned].map(i => i.__initSymb());
this.set(keySymbol, cloned);
}
// opt.symbol2w && cloned.set(keySymbol2w, 1); // opt.symbol2w && cloned.set(keySymbol2w, 1);
} }

Loading…
Cancel
Save