After you have pulled in the Snap.svg.js module, and before your code, add this in a <script>
<script>
Snap.plugin( function( Snap, Element, Paper, global ) {
Element.prototype.cloneKeepIds = function() {
var cloneNode = this.node.cloneNode(true);
var cloneElt = new Element(cloneNode);
cloneElt.insertAfter(this);
return cloneElt;
};
});
</script>
and use it (when needed, with caution, buy insurance first, etc.) instead of Element.clone()
Snap.load(theResource, function(frag) {
// console.log(' Snap.load() returned "',frag,'"');
var myGroup = frag.select('#myShapes');
// console.log(' original group: ', myGroup);
// var myClonedGroup = myGroup.clone();
// console.log(' cloned group: ', myClonedGroup);
var myClonedOther = myGroup.cloneKeepIds();
console.log(' alternate clone: ', myClonedOther);
: : : :
Again, Snap.svg's Element.clone() is trying very hard not to mess up the links/relationships between elements if such are used, which is why it takes control of
.id values. But the above skips over all that and chooses to implement the simple and dumb clone.
I wonder if we could get a Boolean added to Element.clone() ? :-)