I have a hunch that this could be because you are cloning a linear gradient that has an id attribute (which, of course, must be unique throughout the document). This can confuse the SVG processor.
My theory seems to be confirmed by changing the identifier on the clone path:
$('input[value="copy"]').click(function () { var clone = $("#orgdiv").clone();
... which seems to prevent the problem. (In this case, the clone still gets the gradient, even if the identifier of its cloned gradient has changed since it detects the original gradient by its identifier.)
JSFiddle here: http://jsfiddle.net/2K4xv/2/
I assume that what happens โunder the hoodโ in your case is that the processor picks up the second gradient filter element that you create for use with the first circle, and then lose the link to it when it is destroyed by your empty() , thereby leaving you with a circle, but without a gradient. That is why this happens only for the second time, probably, down to the details of the implementation of SVG rendering of interaction with an HTML5 document.
More information on this in this earlier question .
source share