summaryrefslogtreecommitdiffstats
path: root/src/parent.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/parent.js')
-rwxr-xr-xsrc/parent.js11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/parent.js b/src/parent.js
index 55878ec..095120a 100755
--- a/src/parent.js
+++ b/src/parent.js
@@ -18,10 +18,10 @@ SVG.Parent = SVG.invent({
// Add given element at a position
, add: function(element, i) {
if (!this.has(element)) {
- /* define insertion index if none given */
+ // Define insertion index if none given
i = i == null ? this.children().length : i
- /* add element references */
+ // Add element references
this.node.insertBefore(element.node, this.node.childNodes[i] || null)
}
@@ -78,9 +78,10 @@ SVG.Parent = SVG.invent({
// Remove children
while(this.node.hasChildNodes())
this.node.removeChild(this.node.lastChild)
-
- // Remove defs cache reference
- delete this._defs
+
+ // Ensure new defs node
+ if (this instanceof SVG.Doc)
+ this.defs()
return this
}