diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-26 20:59:57 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-05-26 20:59:57 +0200 |
commit | 7990dc47fda4f3b850c18318775ab108c2aff8f5 (patch) | |
tree | 9a2ed0eba0a75765e20193e0f3b51d2286cddf62 /src/doc.js | |
parent | 07d1e87bb4843f954e9340a6206df34d294a847a (diff) | |
download | svg.js-7990dc47fda4f3b850c18318775ab108c2aff8f5.tar.gz svg.js-7990dc47fda4f3b850c18318775ab108c2aff8f5.zip |
fixed issues in SVG.Doc and SVG.Mask when cloning(#782)
Diffstat (limited to 'src/doc.js')
-rw-r--r-- | src/doc.js | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -53,7 +53,8 @@ SVG.Doc = SVG.invent({ } // custom parent method , parent: function() { - return this.node.parentNode.nodeName == '#document' ? null : this.node.parentNode + if(!this.node.parentNode || this.node.parentNode.nodeName == '#document') return null + return this.node.parentNode } // Fix for possible sub-pixel offset. See: // https://bugzilla.mozilla.org/show_bug.cgi?id=608812 @@ -90,6 +91,25 @@ SVG.Doc = SVG.invent({ return this } + , clone: function (parent) { + // write dom data to the dom so the clone can pickup the data + this.writeDataToDom() + + // get reference to node + var node = this.node + + // clone element and assign new id + var clone = assignNewId(node.cloneNode(true)) + + // insert the clone in the given parent or after myself + if(parent) { + (parent.node || parent).appendChild(clone.node) + } else { + node.parentNode.insertBefore(clone.node, node.nextSibling) + } + + return clone + } } }) |