summaryrefslogtreecommitdiffstats
path: root/src/modules/optional/arrange.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-26 12:52:57 +1000
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2020-04-26 12:52:57 +1000
commitae26b9a642d9f935f376ff8d211590525f51a71d (patch)
tree3cb76cc68d97a685c71fb88a4d5ff8a9c205b6bf /src/modules/optional/arrange.js
parentbba5002cc8985b9729119bfcadc2de58f4e198a1 (diff)
downloadsvg.js-ae26b9a642d9f935f376ff8d211590525f51a71d.tar.gz
svg.js-ae26b9a642d9f935f376ff8d211590525f51a71d.zip
added tests for sugar.js
Diffstat (limited to 'src/modules/optional/arrange.js')
-rw-r--r--src/modules/optional/arrange.js14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/modules/optional/arrange.js b/src/modules/optional/arrange.js
index 7db4386..b6c03e0 100644
--- a/src/modules/optional/arrange.js
+++ b/src/modules/optional/arrange.js
@@ -23,16 +23,11 @@ export function prev () {
// Send given element one step forward
export function forward () {
- var i = this.position() + 1
+ var i = this.position()
var p = this.parent()
// move node one step forward
- p.removeElement(this).add(this, i)
-
- // make sure defs node is always at the top
- if (typeof p.isRoot === 'function' && p.isRoot()) {
- p.node.appendChild(p.defs().node)
- }
+ p.add(this.remove(), i + 1)
return this
}
@@ -40,10 +35,9 @@ export function forward () {
// Send given element one step backward
export function backward () {
var i = this.position()
+ var p = this.parent()
- if (i > 0) {
- this.parent().removeElement(this).add(this, i - 1)
- }
+ p.add(this.remove(), i ? i - 1 : 0)
return this
}