aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-26 20:59:57 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-05-26 20:59:57 +0200
commit7990dc47fda4f3b850c18318775ab108c2aff8f5 (patch)
tree9a2ed0eba0a75765e20193e0f3b51d2286cddf62 /src/doc.js
parent07d1e87bb4843f954e9340a6206df34d294a847a (diff)
downloadsvg.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.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/doc.js b/src/doc.js
index 85728a2..536630a 100644
--- a/src/doc.js
+++ b/src/doc.js
@@ -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
+ }
}
})