aboutsummaryrefslogtreecommitdiffstats
path: root/src/doc.js
diff options
context:
space:
mode:
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
+ }
}
})