diff options
Diffstat (limited to 'src/modules/optional')
-rw-r--r-- | src/modules/optional/arrange.js | 16 | ||||
-rw-r--r-- | src/modules/optional/class.js | 4 | ||||
-rw-r--r-- | src/modules/optional/data.js | 8 | ||||
-rw-r--r-- | src/modules/optional/memory.js | 4 | ||||
-rw-r--r-- | src/modules/optional/sugar.js | 8 | ||||
-rw-r--r-- | src/modules/optional/transform.js | 14 |
6 files changed, 28 insertions, 26 deletions
diff --git a/src/modules/optional/arrange.js b/src/modules/optional/arrange.js index 30151c1..9aaeef1 100644 --- a/src/modules/optional/arrange.js +++ b/src/modules/optional/arrange.js @@ -23,8 +23,8 @@ export function prev () { // Send given element one step forward export function forward () { - var i = this.position() - var p = this.parent() + const i = this.position() + const p = this.parent() // move node one step forward p.add(this.remove(), i + 1) @@ -34,8 +34,8 @@ export function forward () { // Send given element one step backward export function backward () { - var i = this.position() - var p = this.parent() + const i = this.position() + const p = this.parent() p.add(this.remove(), i ? i - 1 : 0) @@ -44,7 +44,7 @@ export function backward () { // Send given element all the way to the front export function front () { - var p = this.parent() + const p = this.parent() // Move node forward p.add(this.remove()) @@ -54,7 +54,7 @@ export function front () { // Send given element all the way to the back export function back () { - var p = this.parent() + const p = this.parent() // Move node back p.add(this.remove(), 0) @@ -67,7 +67,7 @@ export function before (element) { element = makeInstance(element) element.remove() - var i = this.position() + const i = this.position() this.parent().add(element, i) @@ -79,7 +79,7 @@ export function after (element) { element = makeInstance(element) element.remove() - var i = this.position() + const i = this.position() this.parent().add(element, i + 1) diff --git a/src/modules/optional/class.js b/src/modules/optional/class.js index b08c82b..4e544be 100644 --- a/src/modules/optional/class.js +++ b/src/modules/optional/class.js @@ -3,7 +3,7 @@ import { registerMethods } from '../../utils/methods.js' // Return array of classes on the node export function classes () { - var attr = this.attr('class') + const attr = this.attr('class') return attr == null ? [] : attr.trim().split(delimiter) } @@ -15,7 +15,7 @@ export function hasClass (name) { // Add class to the node export function addClass (name) { if (!this.hasClass(name)) { - var array = this.classes() + const array = this.classes() array.push(name) this.attr('class', array.join(' ')) } diff --git a/src/modules/optional/data.js b/src/modules/optional/data.js index 9986c3d..00bb8ea 100644 --- a/src/modules/optional/data.js +++ b/src/modules/optional/data.js @@ -24,9 +24,11 @@ export function data (a, v, r) { } } else { this.attr('data-' + a, - v === null ? null - : r === true || typeof v === 'string' || typeof v === 'number' ? v - : JSON.stringify(v) + v === null + ? null + : r === true || typeof v === 'string' || typeof v === 'number' + ? v + : JSON.stringify(v) ) } diff --git a/src/modules/optional/memory.js b/src/modules/optional/memory.js index 6478367..459dcf1 100644 --- a/src/modules/optional/memory.js +++ b/src/modules/optional/memory.js @@ -4,7 +4,7 @@ import { registerMethods } from '../../utils/methods.js' export function remember (k, v) { // remember every item in an object individually if (typeof arguments[0] === 'object') { - for (var key in k) { + for (const key in k) { this.remember(key, k[key]) } } else if (arguments.length === 1) { @@ -23,7 +23,7 @@ export function forget () { if (arguments.length === 0) { this._memory = {} } else { - for (var i = arguments.length - 1; i >= 0; i--) { + for (let i = arguments.length - 1; i >= 0; i--) { delete this.memory()[arguments[i]] } } diff --git a/src/modules/optional/sugar.js b/src/modules/optional/sugar.js index 13806f1..d4c3da5 100644 --- a/src/modules/optional/sugar.js +++ b/src/modules/optional/sugar.js @@ -6,7 +6,7 @@ import Point from '../../types/Point.js' import SVGNumber from '../../types/SVGNumber.js' // Define list of available attributes for stroke and fill -var sugar = { +const sugar = { stroke: [ 'color', 'width', 'opacity', 'linecap', 'linejoin', 'miterlimit', 'dasharray', 'dashoffset' ], fill: [ 'color', 'opacity', 'rule' ], prefix: function (t, a) { @@ -16,8 +16,8 @@ var sugar = { // Add sugar for fill and stroke ;[ 'fill', 'stroke' ].forEach(function (m) { - var extension = {} - var i + const extension = {} + let i extension[m] = function (o) { if (typeof o === 'undefined') { @@ -104,7 +104,7 @@ registerMethods([ 'Element', 'Runner' ], { registerMethods('radius', { // Add x and y radius radius: function (x, y = x) { - var type = (this._element || this).type + const type = (this._element || this).type return type === 'radialGradient' ? this.attr('r', new SVGNumber(x)) : this.rx(x).ry(y) diff --git a/src/modules/optional/transform.js b/src/modules/optional/transform.js index 68455ed..d8e7381 100644 --- a/src/modules/optional/transform.js +++ b/src/modules/optional/transform.js @@ -10,11 +10,11 @@ export function untransform () { // merge the whole transformation chain into one matrix and returns it export function matrixify () { - var matrix = (this.attr('transform') || '') + const matrix = (this.attr('transform') || '') // split transformations .split(transforms).slice(0, -1).map(function (str) { // generate key => value pairs - var kv = str.trim().split('(') + const kv = str.trim().split('(') return [ kv[0], kv[1].split(delimiter) .map(function (str) { @@ -37,8 +37,8 @@ export function matrixify () { // add an element to another parent without changing the visual representation on the screen export function toParent (parent, i) { if (this === parent) return this - var ctm = this.screenCTM() - var pCtm = parent.screenCTM().inverse() + const ctm = this.screenCTM() + const pCtm = parent.screenCTM().inverse() this.addTo(parent, i).untransform().transform(pCtm.multiply(ctm)) @@ -54,7 +54,7 @@ export function toRoot (i) { export function transform (o, relative) { // Act as a getter if no object was passed if (o == null || typeof o === 'string') { - var decomposed = new Matrix(this).decompose() + const decomposed = new Matrix(this).decompose() return o == null ? decomposed : decomposed[o] } @@ -64,8 +64,8 @@ export function transform (o, relative) { } // The user can pass a boolean, an Element or an Matrix or nothing - var cleanRelative = relative === true ? this : (relative || false) - var result = new Matrix(cleanRelative).transform(o) + const cleanRelative = relative === true ? this : (relative || false) + const result = new Matrix(cleanRelative).transform(o) return this.attr('transform', result) } |