summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/arrange.js24
-rwxr-xr-xsrc/parent.js5
2 files changed, 23 insertions, 6 deletions
diff --git a/src/arrange.js b/src/arrange.js
index 5c4e878..b6721b4 100755
--- a/src/arrange.js
+++ b/src/arrange.js
@@ -20,8 +20,17 @@ SVG.extend(SVG.Element, {
}
// Send given element one step forward
, forward: function() {
- var i = this.position()
- return this.parent().removeElement(this).put(this, i + 1)
+ var i = this.position() + 1
+ , p = this.parent()
+
+ // Move node one step forward
+ p.removeElement(this).add(this, i)
+
+ // Make sure defs node is always at the top
+ if (p instanceof SVG.Doc)
+ p.node.appendChild(p.defs().node)
+
+ return this
}
// Send given element one step backward
, backward: function() {
@@ -34,7 +43,16 @@ SVG.extend(SVG.Element, {
}
// Send given element all the way to the front
, front: function() {
- return this.parent().removeElement(this).put(this)
+ var p = this.parent()
+
+ // Move node forward
+ p.node.appendChild(this.node)
+
+ // Make sure defs node is always at the top
+ if (p instanceof SVG.Doc)
+ p.node.appendChild(p.defs().node)
+
+ return this
}
// Send given element all the way to the back
, back: function() {
diff --git a/src/parent.js b/src/parent.js
index 095120a..bde35da 100755
--- a/src/parent.js
+++ b/src/parent.js
@@ -79,9 +79,8 @@ SVG.Parent = SVG.invent({
while(this.node.hasChildNodes())
this.node.removeChild(this.node.lastChild)
- // Ensure new defs node
- if (this instanceof SVG.Doc)
- this.defs()
+ // Remove defs reference
+ delete this._defs
return this
}