summaryrefslogtreecommitdiffstats
path: root/src/container.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-06-27 16:36:26 +0100
committerwout <wout@impinc.co.uk>2013-06-27 16:36:26 +0100
commit8cb2aba17829e6c9de15206b891e6c878b306a7b (patch)
tree6d3c45e02e918de27e5208f7f6516f48fe62551e /src/container.js
parent46909dc19338e649702b6ea852120af5132bc086 (diff)
downloadsvg.js-8cb2aba17829e6c9de15206b891e6c878b306a7b.tar.gz
svg.js-8cb2aba17829e6c9de15206b891e6c878b306a7b.zip
Reworked arrange module, <defs> always on top
Diffstat (limited to 'src/container.js')
-rw-r--r--src/container.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/container.js b/src/container.js
index cb010f2..f928c54 100644
--- a/src/container.js
+++ b/src/container.js
@@ -28,6 +28,12 @@ SVG.extend(SVG.Container, {
this.node.insertBefore(element.node, this.node.childNodes[i] || null)
element.parent = this
}
+
+ /* reposition defs */
+ if (this._defs) {
+ this.node.removeChild(this._defs.node)
+ this.node.appendChild(this._defs.node)
+ }
return this
}
@@ -50,7 +56,7 @@ SVG.extend(SVG.Container, {
, children = this.children()
for (i = 0, il = children.length; i < il; i++) {
- if (children[i] instanceof SVG.Shape)
+ if (children[i] instanceof SVG.Element)
block.apply(children[i], [i, children])
if (deep && (children[i] instanceof SVG.Container))
@@ -69,13 +75,9 @@ SVG.extend(SVG.Container, {
return this
}
- // Returns defs element
+ // Get defs
, defs: function() {
- return this._defs || (this._defs = this.put(new SVG.Defs, 0))
- }
- // Re-level defs to first positon in element stack
-, level: function() {
- return this.removeElement(this.defs()).put(this.defs(), 0)
+ return this.doc().defs()
}
// Get first child, skipping the defs node
, first: function() {
@@ -105,10 +107,8 @@ SVG.extend(SVG.Container, {
this.removeElement(this.children()[i])
/* remove defs node */
- if (this._defs) {
- this._defs.remove()
- delete this._defs
- }
+ if (this._defs)
+ this._defs.clear()
return this
}