I've read your bug-report , I've added a few lines
to print some stuff and I will comment it.
Since from Perl 5.7.3 we have Storable coming with Perl itself,
why would we need to re-write a recursive cloning every time.
So , in order to fix the problem , I think it's better we use
dclone from Storable.
Patch rolled in.
#!/usr/bin/perl
use strict;
use warnings;
use SVG;
my $original_svg = my $svg = SVG->new(-nocredits => 1);
$svg->g(id => "g");
#warn $svg->xmlify;
$svg = $svg->cloneNode(1);
#After this $svg != $original_svg
#and $svg is now of type SVG::Element and $original_svg is SVG.
$svg->getElementByID("g")->setAttribute("style", "stroke: #aaa");
#(1) now $svg will have attribute style "stroke: #aaa" on tag <g>
#(2) and $original_svg will not.
say $svg;
say $original_svg;
say $svg->getElementByID("g");
say $original_svg->getElementByID("g");
#we get output
#
#SVG::Element=HASH(0x97a0eb0)
#SVG=HASH(0x9799e28)
#SVG::Element=HASH(0x96f29c8)
#SVG::Element=HASH(0x96f29c8)
# So although our objects are distinct , some children of the cloned
# nodes AREN'T !!! So cloneNode indeed does not do a proper cloning
# although we have given as argument to cloneNode 1 which means we're
# doin DEEP cloning.
warn "No stroke!" unless $svg->xmlify =~ m/#aaa/;
#this should not be shown because of (1)
die "Has stroke!" if $original_svg->xmlify =~ m/#aaa/;
#this should not die because of (2).