aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2021-01-13 17:26:33 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2021-01-13 17:26:33 +0100
commit4524c20b48abe08e69c25a7382a289592d147496 (patch)
tree3e475fe673d5acd800180282e84df03d396106f3 /src/utils
parent4f4dc2afa62cb899a5cae72c359150f8adf27edb (diff)
downloadsvg.js-4524c20b48abe08e69c25a7382a289592d147496.tar.gz
svg.js-4524c20b48abe08e69c25a7382a289592d147496.zip
update dependencies, apply new linter fixes
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/adopter.js8
-rw-r--r--src/utils/pathParser.js4
-rw-r--r--src/utils/utils.js52
3 files changed, 37 insertions, 27 deletions
diff --git a/src/utils/adopter.js b/src/utils/adopter.js
index a440e4c..048eb9c 100644
--- a/src/utils/adopter.js
+++ b/src/utils/adopter.js
@@ -29,7 +29,7 @@ export function makeInstance (element, isHTML = false) {
}
// Make sure, that HTML elements are created with the correct namespace
- var wrapper = isHTML ? globals.document.createElement('div') : create('svg')
+ const wrapper = isHTML ? globals.document.createElement('div') : create('svg')
wrapper.innerHTML = element
// We can use firstChild here because we know,
@@ -58,7 +58,7 @@ export function adopt (node) {
}
// initialize variables
- var className = capitalize(node.nodeName || 'Dom')
+ let className = capitalize(node.nodeName || 'Dom')
// Make sure that gradients are adopted correctly
if (className === 'LinearGradient' || className === 'RadialGradient') {
@@ -102,7 +102,7 @@ export function eid (name) {
// Deep new id assignment
export function assignNewId (node) {
// do the same for SVG child nodes as well
- for (var i = node.children.length - 1; i >= 0; i--) {
+ for (let i = node.children.length - 1; i >= 0; i--) {
assignNewId(node.children[i])
}
@@ -116,7 +116,7 @@ export function assignNewId (node) {
// Method for extending objects
export function extend (modules, methods) {
- var key, i
+ let key, i
modules = Array.isArray(modules) ? modules : [ modules ]
diff --git a/src/utils/pathParser.js b/src/utils/pathParser.js
index 54e22e6..1d0ee86 100644
--- a/src/utils/pathParser.js
+++ b/src/utils/pathParser.js
@@ -57,7 +57,7 @@ const pathHandlers = {
const mlhvqtcsaz = 'mlhvqtcsaz'.split('')
-for (var i = 0, il = mlhvqtcsaz.length; i < il; ++i) {
+for (let i = 0, il = mlhvqtcsaz.length; i < il; ++i) {
pathHandlers[mlhvqtcsaz[i]] = (function (i) {
return function (c, p, p0) {
if (i === 'H') c[0] = c[0] + p.x
@@ -66,7 +66,7 @@ for (var i = 0, il = mlhvqtcsaz.length; i < il; ++i) {
c[5] = c[5] + p.x
c[6] = c[6] + p.y
} else {
- for (var j = 0, jl = c.length; j < jl; ++j) {
+ for (let j = 0, jl = c.length; j < jl; ++j) {
c[j] = c[j] + (j % 2 ? p.y : p.x)
}
}
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 927f044..7d08e22 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -1,8 +1,8 @@
// Map function
export function map (array, block) {
- var i
- var il = array.length
- var result = []
+ let i
+ const il = array.length
+ const result = []
for (i = 0; i < il; i++) {
result.push(block(array[i]))
@@ -13,9 +13,9 @@ export function map (array, block) {
// Filter function
export function filter (array, block) {
- var i
- var il = array.length
- var result = []
+ let i
+ const il = array.length
+ const result = []
for (i = 0; i < il; i++) {
if (block(array[i])) {
@@ -81,18 +81,24 @@ export function proportionalSize (element, width, height, box) {
export function getOrigin (o, element) {
const origin = o.origin
// First check if origin is in ox or originX
- let ox = o.ox != null ? o.ox
- : o.originX != null ? o.originX
- : 'center'
- let oy = o.oy != null ? o.oy
- : o.originY != null ? o.originY
- : 'center'
+ let ox = o.ox != null
+ ? o.ox
+ : o.originX != null
+ ? o.originX
+ : 'center'
+ let oy = o.oy != null
+ ? o.oy
+ : o.originY != null
+ ? o.originY
+ : 'center'
// Then check if origin was used and overwrite in that case
if (origin != null) {
- [ ox, oy ] = Array.isArray(origin) ? origin
- : typeof origin === 'object' ? [ origin.x, origin.y ]
- : [ origin, origin ]
+ [ ox, oy ] = Array.isArray(origin)
+ ? origin
+ : typeof origin === 'object'
+ ? [ origin.x, origin.y ]
+ : [ origin, origin ]
}
// Make sure to only call bbox when actually needed
@@ -103,15 +109,19 @@ export function getOrigin (o, element) {
// And only overwrite if string was passed for this specific axis
if (condX) {
- ox = ox.includes('left') ? x
- : ox.includes('right') ? x + width
- : x + width / 2
+ ox = ox.includes('left')
+ ? x
+ : ox.includes('right')
+ ? x + width
+ : x + width / 2
}
if (condY) {
- oy = oy.includes('top') ? y
- : oy.includes('bottom') ? y + height
- : y + height / 2
+ oy = oy.includes('top')
+ ? y
+ : oy.includes('bottom')
+ ? y + height
+ : y + height / 2
}
}