diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-26 12:52:57 +1000 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2020-04-26 12:52:57 +1000 |
commit | ae26b9a642d9f935f376ff8d211590525f51a71d (patch) | |
tree | 3cb76cc68d97a685c71fb88a4d5ff8a9c205b6bf /src/modules/optional/arrange.js | |
parent | bba5002cc8985b9729119bfcadc2de58f4e198a1 (diff) | |
download | svg.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.js | 14 |
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 } |