A jQuery plugin that clones only the *structure* of a jQuery collection of nodes -- i.e., only the tree of nodes itself, without any of the various classes, attributes, etc., on the elements of the tree. Optionally, the plugin can be used to remove only the id attributes from a collection of nodes, leaving the remaining attributes and classes (etc.) in tact.
jQuery's native .clone method takes two optional arguments, withDataAndEvents and deepWithDataAndEvents. See the documentation here: https://api.jquery.com/clone/. .cloneStructure should also accept (and pass on) those optional arguments, so that data and events are cloned in accordance with the user's specifications.
jQuery's documentation for the .clone method has the following note:
Note: Using .clone() has the side-effect of producing elements with duplicate id attributes, which are supposed to be unique. Where possible, it is recommended to avoid cloning elements with this attribute or using class attributes as identifiers instead.
.cloneStructure already removes ids, so this isn't an immediate issue. However, it would be nice for .cloneStructure to take a third optional argument, removeOnlyIds, that will tell the method whether it should only remove ids and leave the other attributes in the cloned structure, thereby allowing this method to resolve an independent issue with jQuery's .clone method in a more targeted fashion.