aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules
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
parentbba5002cc8985b9729119bfcadc2de58f4e198a1 (diff)
downloadsvg.js-ae26b9a642d9f935f376ff8d211590525f51a71d.tar.gz
svg.js-ae26b9a642d9f935f376ff8d211590525f51a71d.zip
added tests for sugar.js
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/optional/arrange.js14
-rw-r--r--src/modules/optional/sugar.js7
2 files changed, 7 insertions, 14 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
}
diff --git a/src/modules/optional/sugar.js b/src/modules/optional/sugar.js
index 72c02ca..13806f1 100644
--- a/src/modules/optional/sugar.js
+++ b/src/modules/optional/sugar.js
@@ -1,4 +1,3 @@
-import { on, off } from '../core/event.js'
import { registerMethods } from '../../utils/methods.js'
import Color from '../../types/Color.js'
import Element from '../../elements/Element.js'
@@ -106,7 +105,7 @@ registerMethods('radius', {
// Add x and y radius
radius: function (x, y = x) {
var type = (this._element || this).type
- return type === 'radialGradient' || type === 'radialGradient'
+ return type === 'radialGradient'
? this.attr('r', new SVGNumber(x))
: this.rx(x).ry(y)
}
@@ -159,9 +158,9 @@ const methods = [ 'click',
// add event to Element
const fn = function (f) {
if (f === null) {
- off(this, event)
+ this.off(event)
} else {
- on(this, event, f)
+ this.on(event, f)
}
return this
}