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
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.
The text was updated successfully, but these errors were encountered:
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.
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.
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 theclone()
function would be sufficient.The text was updated successfully, but these errors were encountered: