diff options
author | wout <wout@impinc.co.uk> | 2014-06-26 08:16:14 +0200 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-06-26 08:16:14 +0200 |
commit | 58b1a0b92ba78e0ce2047e41caa02f65d16cd557 (patch) | |
tree | af6b54d85b9affcf8e1b78612d17d620bc7db17f /src/element.js | |
parent | 2bc1909290d90ba9c38474361d62d7f6bcc3e95b (diff) | |
download | svg.js-58b1a0b92ba78e0ce2047e41caa02f65d16cd557.tar.gz svg.js-58b1a0b92ba78e0ce2047e41caa02f65d16cd557.zip |
Complete new clone() method
Diffstat (limited to 'src/element.js')
-rwxr-xr-x | src/element.js | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/src/element.js b/src/element.js index 753ac33..069c487 100755 --- a/src/element.js +++ b/src/element.js @@ -67,36 +67,7 @@ SVG.Element = SVG.invent({ } // Clone element , clone: function() { - var clone , attr - , type = this.type - - /* invoke shape method with shape-specific arguments */ - clone = type == 'rect' || type == 'ellipse' ? - this.parent()[type](0,0) : - type == 'line' ? - this.parent()[type](0,0,0,0) : - type == 'image' ? - this.parent()[type](this.src) : - type == 'text' ? - this.parent()[type](this.content) : - type == 'path' ? - this.parent()[type](this.attr('d')) : - type == 'polyline' || type == 'polygon' ? - this.parent()[type](this.attr('points')) : - type == 'g' ? - this.parent().group() : - this.parent()[type]() - - /* apply attributes attributes */ - attr = this.attr() - delete attr.id - clone.attr(attr) - - /* copy transformations */ - clone.trans = this.trans - - /* apply attributes and translations */ - return clone.transform({}) + return assignNewId(this.node.cloneNode(true)) } // Remove element , remove: function() { |