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

Implement way to create childless clone #941

Closed
iconexperience opened this issue Feb 4, 2016 · 4 comments
Closed

Implement way to create childless clone #941

iconexperience opened this issue Feb 4, 2016 · 4 comments

Comments

@iconexperience
Copy link
Contributor

Sometimes it is necessary to create a partial clone of an item hierarchy. Instead of cloning the full item tree and removing the unwanted child items afterwards, it would be more efficient to recusively create a childless clone for an item and add only the required children.

Implementing this should be very easy, because copying attributes and children has been separated already.

Regarding the API, only introducing a second optional parameter called childless in the clone() function would be sufficient.

@lehni
Copy link
Member

lehni commented Feb 4, 2016

For this we should consider converting the argument to clone to an options object. If a boolean is passed, then it should still assume it's the insert value, for backwards compatibility.

Instead of calling it childless, how about flat / deep? If it's deep (which I prefer), then the default would be true.

@iconexperience
Copy link
Contributor Author

I think I remember a discussion about using a deep option to also clone the segments of a path (which is not done with a clone, if I understand correctly). But with an options object it would certainly be possible to add another flag for doing this later.

Aside from that an option with flags insert and flat is certainly a very good idea, and the distinction between true/false and an options object for backwards compatibility makes a lot of sense.

@lehni
Copy link
Member

lehni commented Feb 4, 2016

A clone at the moment copies everything, segments included.

@iconexperience
Copy link
Contributor Author

You are correct, of course. Not sure why I was thinking it would be different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants