Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some sort of deep cloning of objects #2397

Closed
wants to merge 1 commit into from
Closed

Some sort of deep cloning of objects #2397

wants to merge 1 commit into from

Conversation

asturur
Copy link
Member

@asturur asturur commented Aug 8, 2015

Possible fix for #2396.

Not really sure if it can break something.

@asturur asturur changed the title Update lang_object.js Some sort of deep cloning of objects Aug 8, 2015
@kangax
Copy link
Member

kangax commented Aug 10, 2015

Technically, this is a back-incompatible change in behavior so... this could break things in some applications, yes; we'd need to bump version. I'm not sure about changing extend to be deep clone because deep clone comes with its own problems like taking care of circular references. It's also a tad slower, which would make entire Fabric slower. Lodash, for example, provides clone and a separate cloneDeep (https://lodash.com/docs#cloneDeep). One option for us would be to introduce 3rd argument — isDeep (true | false), default being false.

@kangax
Copy link
Member

kangax commented Aug 10, 2015

You could see lodash taking care of circular references and other things like arguments object (which has a [[Class]] of "[object Arguments]") or host objects — https://github.com/lodash/lodash/blob/3.10.1/lodash.src.js#L1817-L1871

@asturur
Copy link
Member Author

asturur commented Aug 10, 2015

lets have as a reminder. all itext cloning and objects with transform matrix are cloned with references instead of values.
also polygon's array of points and path commands.
group's list of objects. all referenced.

at least in toObject method of object.class,
transformatrix should be extend([], this.transformMatrix).

@kangax
Copy link
Member

kangax commented Aug 10, 2015

transformatrix should be extend([], this.transformMatrix).

we can just do that for now

@asturur asturur closed this Sep 2, 2015
@asturur asturur deleted the change-in-clone-method branch September 2, 2015 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants