You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I happen to have a Typescript object with getters and setters set as one of the attribute on a Cell: cell.attr(keyPath, tsObj)
A call to cell.removeAttr('someKeyPath') where someKeyPath doesn't involve the tsObj above corrupts the tsObj such that it becomes unusable all of a sudden. The culprit seems to be joint.util.cloneDeep(obj) that deep clones cell.attributes.attrs.
Is there anyway to leave TS objects (with prototype chain) untouched by deep clone? Treat them as other mutable types such as number and string?
This is a common problem it seems. For example this: angular/angular.js#5085
That was working in 1.X versions i think.
The text was updated successfully, but these errors were encountered:
To be on the same page, the attrs attribute suppose to store only the SVG presentation attributes. It's a hash, where keys are the selectors to an SVGElement and values are SVG attributes, which will be set to the SVGElement. Any other model-related data are meant to be stored outside the attrs object.
// a presentation attribute <text fontSize=16></text>// element.attributes.attrs.label.fontSizeelement.attr('label/fontSize',16);// a custom data// element.attributes.myDataelement.prop('myData',{test: true});// WRONG// <text my-data="[object Object]></text>"element.attr('label/myData',{test: true});
So unless your tsObj getters dynamically return presentation attributes, you can avoid this issue by storing your data outside the attrs object.
Not, the cloning is necessary so the Backbone triggers a change event. In this case of removeProp() though, a simple shallow copy should also does the trick (I think).
@kumilingus thank you! Should have thought about overriding joint.util.deepClone myself :-) I'll find time to move out properties from attrs outside of it somewhere. Thanks again!
I happen to have a Typescript object with getters and setters set as one of the attribute on a Cell:
cell.attr(keyPath, tsObj)
A call to
cell.removeAttr('someKeyPath')
wheresomeKeyPath
doesn't involve thetsObj
above corrupts thetsObj
such that it becomes unusable all of a sudden. The culprit seems to bejoint.util.cloneDeep(obj)
that deep clonescell.attributes.attrs
.Is there anyway to leave TS objects (with prototype chain) untouched by deep clone? Treat them as other mutable types such as
number
andstring
?This is a common problem it seems. For example this: angular/angular.js#5085
That was working in 1.X versions i think.
The text was updated successfully, but these errors were encountered: