summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-21 21:19:06 +0200
committerwout <wout@impinc.co.uk>2014-06-21 21:19:06 +0200
commit0bb294ad9189797014b1e1bf55e41ca4b1ead19e (patch)
tree4e4c5004beea90033e9fe80846c9a4c0b2b2ba30 /src
parent629a01b3bbf057eae7e0599433bbbcb28acd8587 (diff)
downloadsvg.js-0bb294ad9189797014b1e1bf55e41ca4b1ead19e.tar.gz
svg.js-0bb294ad9189797014b1e1bf55e41ca4b1ead19e.zip
Back on track with the specs
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
}