summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2019-11-01 13:37:24 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2019-11-01 13:37:24 +0100
commit2827a27531c661726d204d6da9d17c6f72d8e404 (patch)
treea4180b1f462685cce0c314be16511a630d222b05 /src
parent0748382e9859c31253d93b0c258487da362bcade (diff)
downloadsvg.js-2827a27531c661726d204d6da9d17c6f72d8e404.tar.gz
svg.js-2827a27531c661726d204d6da9d17c6f72d8e404.zip
Updated dependencies to newest version, new linter fixed stuff
Diffstat (limited to 'src')
-rw-r--r--src/animation/Controller.js2
-rw-r--r--src/animation/Morphable.js4
-rw-r--r--src/animation/Runner.js20
-rw-r--r--src/animation/Timeline.js20
-rw-r--r--src/elements/ClipPath.js2
-rw-r--r--src/elements/Defs.js1
-rw-r--r--src/elements/Dom.js8
-rw-r--r--src/elements/Element.js8
-rw-r--r--src/modules/core/attr.js2
-rw-r--r--src/modules/core/defaults.js4
-rw-r--r--src/modules/core/event.js2
-rw-r--r--src/modules/core/namespaces.js8
-rw-r--r--src/modules/core/parser.js6
-rw-r--r--src/modules/core/pointed.js6
-rw-r--r--src/modules/core/poly.js2
-rw-r--r--src/modules/core/regex.js38
-rw-r--r--src/modules/optional/css.js10
-rw-r--r--src/types/Box.js16
-rw-r--r--src/types/Color.js26
-rw-r--r--src/types/EventTarget.js4
-rw-r--r--src/types/List.js2
-rw-r--r--src/types/Matrix.js22
-rw-r--r--src/types/PathArray.js4
-rw-r--r--src/types/Point.js7
-rw-r--r--src/utils/adopter.js4
-rw-r--r--src/utils/methods.js4
-rw-r--r--src/utils/utils.js6
27 files changed, 119 insertions, 119 deletions
diff --git a/src/animation/Controller.js b/src/animation/Controller.js
index 6cf58cd..35fa1ae 100644
--- a/src/animation/Controller.js
+++ b/src/animation/Controller.js
@@ -16,7 +16,7 @@ function makeSetterGetter (k, f) {
}
}
-export let easing = {
+export const easing = {
'-': function (pos) {
return pos
},
diff --git a/src/animation/Morphable.js b/src/animation/Morphable.js
index 0f191c9..93debe7 100644
--- a/src/animation/Morphable.js
+++ b/src/animation/Morphable.js
@@ -211,8 +211,8 @@ export class ObjectBag {
objOrArr = objOrArr || {}
var entries = []
- for (let i in objOrArr) {
- entries.push([i, objOrArr[i]])
+ for (const i in objOrArr) {
+ entries.push([ i, objOrArr[i] ])
}
entries.sort((a, b) => {
diff --git a/src/animation/Runner.js b/src/animation/Runner.js
index fb64005..9568b70 100644
--- a/src/animation/Runner.js
+++ b/src/animation/Runner.js
@@ -185,7 +185,7 @@ export default class Runner extends EventTarget {
if (time == null) {
return this._time
}
- let dt = time - this._time
+ const dt = time - this._time
this.step(dt)
return this
}
@@ -373,7 +373,7 @@ export default class Runner extends EventTarget {
if (this._history[method]) {
// if the last method wasnt even initialised, throw it away
if (!this._history[method].caller.initialised) {
- let index = this._queue.indexOf(this._history[method].caller)
+ const index = this._queue.indexOf(this._history[method].caller)
this._queue.splice(index, 1)
return false
}
@@ -513,8 +513,8 @@ const getRunnerTransform = (runner) => runner.transforms
function mergeTransforms () {
// Find the matrix to apply to the element and apply it
- let runners = this._transformationRunners.runners
- let netTransform = runners
+ const runners = this._transformationRunners.runners
+ const netTransform = runners
.map(getRunnerTransform)
.reduce(lmultiply, new Matrix())
@@ -535,7 +535,7 @@ class RunnerArray {
add (runner) {
if (this.runners.includes(runner)) return
- let id = runner.id + 1
+ const id = runner.id + 1
this.runners.push(runner)
this.ids.push(id)
@@ -548,7 +548,7 @@ class RunnerArray {
}
remove (id) {
- let index = this.ids.indexOf(id + 1)
+ const index = this.ids.indexOf(id + 1)
this.ids.splice(index, 1)
this.runners.splice(index, 1)
return this
@@ -577,7 +577,7 @@ class RunnerArray {
}
edit (id, newRunner) {
- let index = this.ids.indexOf(id + 1)
+ const index = this.ids.indexOf(id + 1)
this.ids.splice(index, 1, id + 1)
this.runners.splice(index, 1, newRunner)
return this
@@ -588,7 +588,7 @@ class RunnerArray {
}
clearBefore (id) {
- let deleteCnt = this.ids.indexOf(id + 1) || 1
+ const deleteCnt = this.ids.indexOf(id + 1) || 1
this.ids.splice(0, deleteCnt, 0)
this.runners.splice(0, deleteCnt, new FakeRunner())
.forEach((r) => r.clearTransformsFromQueue())
@@ -760,7 +760,7 @@ extend(Runner, {
// on this runner. We are absolute. We dont need these!
if (!relative) this.clearTransform()
- let { x, y } = new Point(origin).transform(element._currentTransform(this))
+ const { x, y } = new Point(origin).transform(element._currentTransform(this))
let target = new Matrix({ ...transforms, origin: [ x, y ] })
let start = this._isDeclarative && current
@@ -797,7 +797,7 @@ extend(Runner, {
morpher.from(start)
morpher.to(target)
- let affineParameters = morpher.at(pos)
+ const affineParameters = morpher.at(pos)
currentAngle = affineParameters.rotate
current = new Matrix(affineParameters)
diff --git a/src/animation/Timeline.js b/src/animation/Timeline.js
index d09deef..2137727 100644
--- a/src/animation/Timeline.js
+++ b/src/animation/Timeline.js
@@ -11,7 +11,7 @@ var makeSchedule = function (runnerInfo) {
}
const defaultSource = function () {
- let w = globals.window
+ const w = globals.window
return (w.performance || w.Date).now()
}
@@ -68,7 +68,7 @@ export default class Timeline extends EventTarget {
} else if (when === 'now') {
absoluteStartTime = this._time
} else if (when === 'relative') {
- let runnerInfo = this._runners[runner.id]
+ const runnerInfo = this._runners[runner.id]
if (runnerInfo) {
absoluteStartTime = runnerInfo.start + delay
delay = 0
@@ -121,10 +121,10 @@ export default class Timeline extends EventTarget {
getEndTimeOfTimeline () {
let lastEndTime = 0
for (var i = 0; i < this._runners.length; i++) {
- let runnerInfo = this._runners[i]
+ const runnerInfo = this._runners[i]
var duration = runnerInfo ? runnerInfo.runner.duration() : 0
var startTime = runnerInfo ? runnerInfo.start : 0
- let endTime = startTime + duration
+ const endTime = startTime + duration
if (endTime > lastEndTime) {
lastEndTime = endTime
}
@@ -232,12 +232,12 @@ export default class Timeline extends EventTarget {
// this can be solved by reseting them backwards
for (var k = this._runners.length; k--;) {
// Get and run the current runner and ignore it if its inactive
- let runnerInfo = this._runners[k]
- let runner = runnerInfo.runner
+ const runnerInfo = this._runners[k]
+ const runner = runnerInfo.runner
// Make sure that we give the actual difference
// between runner start time and now
- let dtToStart = this._time - runnerInfo.start
+ const dtToStart = this._time - runnerInfo.start
// Dont run runner if not started yet
// and try to reset it
@@ -250,13 +250,13 @@ export default class Timeline extends EventTarget {
var runnersLeft = false
for (var i = 0, len = this._runners.length; i < len; i++) {
// Get and run the current runner and ignore it if its inactive
- let runnerInfo = this._runners[i]
- let runner = runnerInfo.runner
+ const runnerInfo = this._runners[i]
+ const runner = runnerInfo.runner
let dt = dtTime
// Make sure that we give the actual difference
// between runner start time and now
- let dtToStart = this._time - runnerInfo.start
+ const dtToStart = this._time - runnerInfo.start
// Dont run runner if not started yet
if (dtToStart <= 0) {
diff --git a/src/elements/ClipPath.js b/src/elements/ClipPath.js
index eb21c21..0a87bed 100644
--- a/src/elements/ClipPath.js
+++ b/src/elements/ClipPath.js
@@ -35,7 +35,7 @@ registerMethods({
// Distribute clipPath to svg element
clipWith (element) {
// use given clip or create a new one
- let clipper = element instanceof ClipPath
+ const clipper = element instanceof ClipPath
? element
: this.parent().clip().add(element)
diff --git a/src/elements/Defs.js b/src/elements/Defs.js
index d5e31e7..1bd3bd4 100644
--- a/src/elements/Defs.js
+++ b/src/elements/Defs.js
@@ -9,6 +9,7 @@ export default class Defs extends Container {
flatten () {
return this
}
+
ungroup () {
return this
}
diff --git a/src/elements/Dom.js b/src/elements/Dom.js
index 3acd199..0c4ecb3 100644
--- a/src/elements/Dom.js
+++ b/src/elements/Dom.js
@@ -242,7 +242,7 @@ export default class Dom extends EventTarget {
// If the user wants outerHTML we need to process this node, too
if (outerHTML) {
- let result = svgOrFn(current)
+ const result = svgOrFn(current)
current = result || current
// The user does not want this node? Well, then he gets nothing
@@ -251,8 +251,8 @@ export default class Dom extends EventTarget {
// Deep loop through all children and apply modifier
current.each(function () {
- let result = svgOrFn(this)
- let _this = result || this
+ const result = svgOrFn(this)
+ const _this = result || this
// If modifier returns false, discard node
if (result === false) {
@@ -288,7 +288,7 @@ export default class Dom extends EventTarget {
fragment.appendChild(well.firstElementChild)
}
- let parent = this.parent()
+ const parent = this.parent()
// Add the whole fragment at once
return outerHTML
diff --git a/src/elements/Element.js b/src/elements/Element.js
index 373ed18..264cea8 100644
--- a/src/elements/Element.js
+++ b/src/elements/Element.js
@@ -70,7 +70,7 @@ export default class Element extends Dom {
// Get parent document
root () {
- let p = this.parent(getClass(root))
+ const p = this.parent(getClass(root))
return p && p.root()
}
@@ -85,7 +85,7 @@ export default class Element extends Dom {
// Checks whether the given point inside the bounding box of the element
inside (x, y) {
- let box = this.bbox()
+ const box = this.bbox()
return x > box.x
&& y > box.y
@@ -101,7 +101,7 @@ export default class Element extends Dom {
// return array of all ancestors of given type up to the root svg
parents (until = globals.document) {
until = makeInstance(until)
- let parents = new List()
+ const parents = new List()
let parent = this
while (
@@ -132,7 +132,7 @@ export default class Element extends Dom {
// Set element size to given width and height
size (width, height) {
- let p = proportionalSize(this, width, height)
+ const p = proportionalSize(this, width, height)
return this
.width(new SVGNumber(p.width))
diff --git a/src/modules/core/attr.js b/src/modules/core/attr.js
index 548a6fb..52c10a0 100644
--- a/src/modules/core/attr.js
+++ b/src/modules/core/attr.js
@@ -17,7 +17,7 @@ export default function attr (attr, val, ns) {
attr = {}
val = this.node.attributes
- for (let node of val) {
+ for (const node of val) {
attr[node.nodeName] = isNumber.test(node.nodeValue)
? parseFloat(node.nodeValue)
: node.nodeValue
diff --git a/src/modules/core/defaults.js b/src/modules/core/defaults.js
index 499d1b4..e8e65b6 100644
--- a/src/modules/core/defaults.js
+++ b/src/modules/core/defaults.js
@@ -2,14 +2,14 @@
export function noop () {}
// Default animation values
-export let timeline = {
+export const timeline = {
duration: 400,
ease: '>',
delay: 0
}
// Default attribute values
-export let attrs = {
+export const attrs = {
// fill and stroke
'fill-opacity': 1,
diff --git a/src/modules/core/event.js b/src/modules/core/event.js
index d9b4f46..2cf9b1e 100644
--- a/src/modules/core/event.js
+++ b/src/modules/core/event.js
@@ -3,7 +3,7 @@ import { makeInstance } from '../../utils/adopter.js'
import { globals } from '../../utils/window.js'
let listenerId = 0
-let windowEvents = {}
+const windowEvents = {}
function getEvents (instance) {
let n = instance.getEventHolder()
diff --git a/src/modules/core/namespaces.js b/src/modules/core/namespaces.js
index 3791298..086e0e9 100644
--- a/src/modules/core/namespaces.js
+++ b/src/modules/core/namespaces.js
@@ -1,5 +1,5 @@
// Default namespaces
-export let ns = 'http://www.w3.org/2000/svg'
-export let xmlns = 'http://www.w3.org/2000/xmlns/'
-export let xlink = 'http://www.w3.org/1999/xlink'
-export let svgjs = 'http://svgjs.com/svgjs'
+export const ns = 'http://www.w3.org/2000/svg'
+export const xmlns = 'http://www.w3.org/2000/xmlns/'
+export const xlink = 'http://www.w3.org/1999/xlink'
+export const svgjs = 'http://svgjs.com/svgjs'
diff --git a/src/modules/core/parser.js b/src/modules/core/parser.js
index 7028044..4f92657 100644
--- a/src/modules/core/parser.js
+++ b/src/modules/core/parser.js
@@ -4,7 +4,7 @@ import { makeInstance } from '../../utils/adopter.js'
export default function parser () {
// Reuse cached element if possible
if (!parser.nodes) {
- let svg = makeInstance().size(2, 0)
+ const svg = makeInstance().size(2, 0)
svg.node.style.cssText = [
'opacity: 0',
'position: absolute',
@@ -16,13 +16,13 @@ export default function parser () {
svg.attr('focusable', 'false')
svg.attr('aria-hidden', 'true')
- let path = svg.path().node
+ const path = svg.path().node
parser.nodes = { svg, path }
}
if (!parser.nodes.svg.node.parentNode) {
- let b = globals.document.body || globals.document.documentElement
+ const b = globals.document.body || globals.document.documentElement
parser.nodes.svg.addTo(b)
}
diff --git a/src/modules/core/pointed.js b/src/modules/core/pointed.js
index 95e6819..540e5f8 100644
--- a/src/modules/core/pointed.js
+++ b/src/modules/core/pointed.js
@@ -1,6 +1,6 @@
import PointArray from '../../types/PointArray.js'
-export let MorphArray = PointArray
+export const MorphArray = PointArray
// Move by left top corner over x-axis
export function x (x) {
@@ -14,12 +14,12 @@ export function y (y) {
// Set width of element
export function width (width) {
- let b = this.bbox()
+ const b = this.bbox()
return width == null ? b.width : this.size(width, b.height)
}
// Set height of element
export function height (height) {
- let b = this.bbox()
+ const b = this.bbox()
return height == null ? b.height : this.size(b.width, height)
}
diff --git a/src/modules/core/poly.js b/src/modules/core/poly.js
index f23b70b..340bdd1 100644
--- a/src/modules/core/poly.js
+++ b/src/modules/core/poly.js
@@ -26,6 +26,6 @@ export function move (x, y) {
// Set element size to given width and height
export function size (width, height) {
- let p = proportionalSize(this, width, height)
+ const p = proportionalSize(this, width, height)
return this.attr('points', this.array().size(p.width, p.height))
}
diff --git a/src/modules/core/regex.js b/src/modules/core/regex.js
index 1056554..2b7b89e 100644
--- a/src/modules/core/regex.js
+++ b/src/modules/core/regex.js
@@ -1,58 +1,58 @@
// Parse unit value
-export let numberAndUnit = /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i
+export const numberAndUnit = /^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i
// Parse hex value
-export let hex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i
+export const hex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i
// Parse rgb value
-export let rgb = /rgb\((\d+),(\d+),(\d+)\)/
+export const rgb = /rgb\((\d+),(\d+),(\d+)\)/
// Parse reference id
-export let reference = /(#[a-z0-9\-_]+)/i
+export const reference = /(#[a-z0-9\-_]+)/i
// splits a transformation chain
-export let transforms = /\)\s*,?\s*/
+export const transforms = /\)\s*,?\s*/
// Whitespace
-export let whitespace = /\s/g
+export const whitespace = /\s/g
// Test hex value
-export let isHex = /^#[a-f0-9]{3,6}$/i
+export const isHex = /^#[a-f0-9]{3,6}$/i
// Test rgb value
-export let isRgb = /^rgb\(/
+export const isRgb = /^rgb\(/
// Test css declaration
-export let isCss = /[^:]+:[^;]+;?/
+export const isCss = /[^:]+:[^;]+;?/
// Test for blank string
-export let isBlank = /^(\s+)?$/
+export const isBlank = /^(\s+)?$/
// Test for numeric string
-export let isNumber = /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i
+export const isNumber = /^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i
// Test for percent value
-export let isPercent = /^-?[\d.]+%$/
+export const isPercent = /^-?[\d.]+%$/
// Test for image url
-export let isImage = /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i
+export const isImage = /\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i
// split at whitespace and comma
-export let delimiter = /[\s,]+/
+export const delimiter = /[\s,]+/
// The following regex are used to parse the d attribute of a path
// Matches all hyphens which are not after an exponent
-export let hyphen = /([^e])-/gi
+export const hyphen = /([^e])-/gi
// Replaces and tests for all path letters
-export let pathLetters = /[MLHVCSQTAZ]/gi
+export const pathLetters = /[MLHVCSQTAZ]/gi
// yes we need this one, too
-export let isPathLetter = /[MLHVCSQTAZ]/i
+export const isPathLetter = /[MLHVCSQTAZ]/i
// matches 0.154.23.45
-export let numbersWithDots = /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi
+export const numbersWithDots = /((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi
// matches .
-export let dots = /\./g
+export const dots = /\./g
diff --git a/src/modules/optional/css.js b/src/modules/optional/css.js
index 2c97f3e..0caf551 100644
--- a/src/modules/optional/css.js
+++ b/src/modules/optional/css.js
@@ -4,7 +4,7 @@ import { registerMethods } from '../../utils/methods.js'
// Dynamic style generator
export function css (style, val) {
- let ret = {}
+ const ret = {}
if (arguments.length === 0) {
// get full style as object
this.node.style.cssText.split(/\s*;\s*/)
@@ -12,7 +12,7 @@ export function css (style, val) {
return !!el.length
})
.forEach(function (el) {
- let t = el.split(/\s*:\s*/)
+ const t = el.split(/\s*:\s*/)
ret[t[0]] = t[1]
})
return ret
@@ -21,8 +21,8 @@ export function css (style, val) {
if (arguments.length < 2) {
// get style properties in the array
if (Array.isArray(style)) {
- for (let name of style) {
- let cased = camelCase(name)
+ for (const name of style) {
+ const cased = camelCase(name)
ret[cased] = this.node.style[cased]
}
return ret
@@ -35,7 +35,7 @@ export function css (style, val) {
// set styles in object
if (typeof style === 'object') {
- for (let name in style) {
+ for (const name in style) {
// set empty string if null/undefined/'' was given
this.node.style[camelCase(name)]
= (style[name] == null || isBlank.test(style[name])) ? '' : style[name]
diff --git a/src/types/Box.js b/src/types/Box.js
index 7621029..5c31535 100644
--- a/src/types/Box.js
+++ b/src/types/Box.js
@@ -51,10 +51,10 @@ export default class Box {
// Merge rect box with another, return a new instance
merge (box) {
- let x = Math.min(this.x, box.x)
- let y = Math.min(this.y, box.y)
- let width = Math.max(this.x + this.width, box.x + box.width) - x
- let height = Math.max(this.y + this.height, box.y + box.height) - y
+ const x = Math.min(this.x, box.x)
+ const y = Math.min(this.y, box.y)
+ const width = Math.max(this.x + this.width, box.x + box.width) - x
+ const height = Math.max(this.y + this.height, box.y + box.height) - y
return new Box(x, y, width, height)
}
@@ -69,7 +69,7 @@ export default class Box {
let yMin = Infinity
let yMax = -Infinity
- let pts = [
+ const pts = [
new Point(this.x, this.y),
new Point(this.x2, this.y),
new Point(this.x, this.y2),
@@ -130,8 +130,8 @@ function getBox (cb, retry) {
export function bbox () {
return new Box(getBox.call(this, (node) => node.getBBox(), (el) => {
try {
- let clone = el.clone().addTo(parser().svg).show()
- let box = clone.node.getBBox()
+ const clone = el.clone().addTo(parser().svg).show()
+ const box = clone.node.getBBox()
clone.remove()
return box
} catch (e) {
@@ -141,7 +141,7 @@ export function bbox () {
}
export function rbox (el) {
- let box = new Box(getBox.call(this, (node) => node.getBoundingClientRect(), (el) => {
+ const box = new Box(getBox.call(this, (node) => node.getBoundingClientRect(), (el) => {
throw new Error('Getting rbox of element "' + el.node.nodeName + '" is not possible')
}))
if (el) return box.transform(el.screenCTM().inverse())
diff --git a/src/types/Color.js b/src/types/Color.js
index 74f20df..e9bc0ce 100644
--- a/src/types/Color.js
+++ b/src/types/Color.js
@@ -68,7 +68,7 @@ export default class Color {
// Reset all values in case the init function is rerun with new color space
if (this.space) {
- for (let component in this.space) {
+ for (const component in this.space) {
delete this[this.space[component]]
}
}
@@ -98,7 +98,7 @@ export default class Color {
const hexParse = v => parseInt(v, 16)
const [ , _a, _b, _c ] = hex.exec(sixDigitHex(a)).map(hexParse)
Object.assign(this, { _a, _b, _c, _d: 0, space: 'rgb' })
- } else throw Error(`Unsupported string format, can't construct Color`)
+ } else throw Error('Unsupported string format, can\'t construct Color')
}
// Now add the components as a convenience
@@ -127,7 +127,7 @@ export default class Color {
// Get the values in the lab space
let { l, a, b } = this
if (this.space === 'lch') {
- let { c, h } = this
+ const { c, h } = this
const dToR = Math.PI / 180
a = c * Math.cos(dToR * h)
b = c * Math.sin(dToR * h)
@@ -153,8 +153,8 @@ export default class Color {
const bU = x * 0.0557 + y * -0.2040 + z * 1.0570
// Convert the values to true rgb values
- let pow = Math.pow
- let bd = 0.0031308
+ const pow = Math.pow
+ const bd = 0.0031308
const r = (rU > bd) ? (1.055 * pow(rU, 1 / 2.4) - 0.055) : 12.92 * rU
const g = (gU > bd) ? (1.055 * pow(gU, 1 / 2.4) - 0.055) : 12.92 * gU
const b = (bU > bd) ? (1.055 * pow(bU, 1 / 2.4) - 0.055) : 12.92 * bU
@@ -173,7 +173,7 @@ export default class Color {
// If we are grey, then just make the color directly
if (s === 0) {
l *= 255
- let color = new Color(l, l, l)
+ const color = new Color(l, l, l)
return color
}
@@ -323,14 +323,14 @@ export default class Color {
*/
_clamped () {
- let { _a, _b, _c } = this.rgb()
- let { max, min, round } = Math
- let format = v => max(0, min(round(v), 255))
+ const { _a, _b, _c } = this.rgb()
+ const { max, min, round } = Math
+ const format = v => max(0, min(round(v), 255))
return [ _a, _b, _c ].map(format)
}
toHex () {
- let [ r, g, b ] = this._clamped().map(componentHex)
+ const [ r, g, b ] = this._clamped().map(componentHex)
return `#${r}${g}${b}`
}
@@ -339,13 +339,13 @@ export default class Color {
}
toRgb () {
- let [ rV, gV, bV ] = this._clamped()
- let string = `rgb(${rV},${gV},${bV})`
+ const [ rV, gV, bV ] = this._clamped()
+ const string = `rgb(${rV},${gV},${bV})`
return string
}
toArray () {
- let { _a, _b, _c, _d, space } = this
+ const { _a, _b, _c, _d, space } = this
return [ _a, _b, _c, _d, space ]
}
diff --git a/src/types/EventTarget.js b/src/types/EventTarget.js
index 06fc9a1..b4a137a 100644
--- a/src/types/EventTarget.js
+++ b/src/types/EventTarget.js
@@ -20,8 +20,8 @@ export default class EventTarget extends Base {
const events = bag[event.type]
- for (let i in events) {
- for (let j in events[i]) {
+ for (const i in events) {
+ for (const j in events[i]) {
events[i][j](event)
}
}
diff --git a/src/types/List.js b/src/types/List.js
index f66e3cd..27f1d5d 100644
--- a/src/types/List.js
+++ b/src/types/List.js
@@ -28,7 +28,7 @@ extend(List, {
}
})
-const reserved = ['toArray', 'constructor', 'each']
+const reserved = [ 'toArray', 'constructor', 'each' ]
List.extend = function (methods) {
methods = methods.reduce((obj, name) => {
diff --git a/src/types/Matrix.js b/src/types/Matrix.js
index c9bf435..c42adf7 100644
--- a/src/types/Matrix.js
+++ b/src/types/Matrix.js
@@ -53,7 +53,7 @@ export default class Matrix {
// Get the proposed transformations and the current transformations
var t = Matrix.formatTransforms(o)
var current = this
- let { x: ox, y: oy } = new Point(t.ox, t.oy).transform(current)
+ const { x: ox, y: oy } = new Point(t.ox, t.oy).transform(current)
// Construct the resulting matrix
var transformer = new Matrix()
@@ -136,8 +136,8 @@ export default class Matrix {
var sy = ((c * sx) / (lam * a - b)) || ((d * sx) / (lam * b + a))
// Use the translations
- let tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy)
- let ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy)
+ const tx = e - cx + cx * ct * sx + cy * (lam * ct * sx - st * sy)
+ const ty = f - cy + cx * st * sx + cy * (lam * st * sx + ct * sy)
// Construct the decomposition and return it
return {
@@ -252,7 +252,7 @@ export default class Matrix {
y = x
}
- let { a, b, c, d, e, f } = this
+ const { a, b, c, d, e, f } = this
this.a = a * x
this.b = b * y
@@ -273,10 +273,10 @@ export default class Matrix {
// Convert degrees to radians
r = radians(r)
- let cos = Math.cos(r)
- let sin = Math.sin(r)
+ const cos = Math.cos(r)
+ const sin = Math.sin(r)
- let { a, b, c, d, e, f } = this
+ const { a, b, c, d, e, f } = this
this.a = a * cos - b * sin
this.b = b * cos + a * sin
@@ -305,7 +305,7 @@ export default class Matrix {
}
shearO (lx, cx = 0, cy = 0) {
- let { a, b, c, d, e, f } = this
+ const { a, b, c, d, e, f } = this
this.a = a + b * lx
this.c = c + d * lx
@@ -331,10 +331,10 @@ export default class Matrix {
x = radians(x)
y = radians(y)
- let lx = Math.tan(x)
- let ly = Math.tan(y)
+ const lx = Math.tan(x)
+ const ly = Math.tan(y)
- let { a, b, c, d, e, f } = this
+ const { a, b, c, d, e, f } = this
this.a = a + b * lx
this.b = b + a * ly
diff --git a/src/types/PathArray.js b/src/types/PathArray.js
index 56df5b6..f124b1b 100644
--- a/src/types/PathArray.js
+++ b/src/types/PathArray.js
@@ -108,7 +108,7 @@ const pathHandlers = {
}
}
-let mlhvqtcsaz = 'mlhvqtcsaz'.split('')
+const mlhvqtcsaz = 'mlhvqtcsaz'.split('')
for (var i = 0, il = mlhvqtcsaz.length; i < il; ++i) {
pathHandlers[mlhvqtcsaz[i]] = (function (i) {
@@ -290,7 +290,7 @@ extend(PathArray, {
// prepare for parsing
var s
- var paramCnt = { 'M': 2, 'L': 2, 'H': 1, 'V': 1, 'C': 6, 'S': 4, 'Q': 4, 'T': 2, 'A': 7, 'Z': 0 }
+ var paramCnt = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 }
if (typeof array === 'string') {
array = array
diff --git a/src/types/Point.js b/src/types/Point.js
index 329b37d..634ffff 100644
--- a/src/types/Point.js
+++ b/src/types/Point.js
@@ -7,11 +7,10 @@ export default class Point {
}
init (x, y) {
- let source
- let base = { x: 0, y: 0 }
+ const base = { x: 0, y: 0 }
// ensure source as object
- source = Array.isArray(x) ? { x: x[0], y: x[1] }
+ const source = Array.isArray(x) ? { x: x[0], y: x[1] }
: typeof x === 'object' ? { x: x.x, y: x.y }
: { x: x, y: y }
@@ -37,7 +36,7 @@ export default class Point {
m = new Matrix(m)
}
- let { x, y } = this
+ const { x, y } = this
// Perform the matrix multiplication
this.x = m.a * x + m.c * y + m.e
diff --git a/src/utils/adopter.js b/src/utils/adopter.js
index 45e9bd3..e8b30ea 100644
--- a/src/utils/adopter.js
+++ b/src/utils/adopter.js
@@ -129,7 +129,7 @@ export function extend (modules, methods, attrCheck) {
export function wrapWithAttrCheck (fn) {
return function (...args) {
- let o = args[args.length - 1]
+ const o = args[args.length - 1]
if (o && o.constructor === Object && !(o instanceof Array)) {
return fn.apply(this, args.slice(0, -1)).attr(o)
@@ -158,7 +158,7 @@ export function invent (config) {
if (config.extend) { extend(initializer, config.extend) }
// Attach construct method to parent
- if (config.construct) { extend(config.parent || elements['Container'], config.construct) }
+ if (config.construct) { extend(config.parent || elements.Container, config.construct) }
return initializer
}
diff --git a/src/utils/methods.js b/src/utils/methods.js
index e957213..45525e3 100644
--- a/src/utils/methods.js
+++ b/src/utils/methods.js
@@ -3,14 +3,14 @@ const names = []
export function registerMethods (name, m) {
if (Array.isArray(name)) {
- for (let _name of name) {
+ for (const _name of name) {
registerMethods(_name, m)
}
return
}
if (typeof name === 'object') {
- for (let _name in name) {
+ for (const _name in name) {
registerMethods(_name, name[_name])
}
return
diff --git a/src/utils/utils.js b/src/utils/utils.js
index c2046a9..5d8706e 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -75,7 +75,7 @@ export function proportionalSize (element, width, height, box) {
export function getOrigin (o, element) {
// Allow origin or around as the names
- let origin = o.origin // o.around == null ? o.origin : o.around
+ const origin = o.origin // o.around == null ? o.origin : o.around
let ox, oy
// Allow the user to pass a string to rotate around a given point
@@ -85,10 +85,10 @@ export function getOrigin (o, element) {
const { height, width, x, y } = element.bbox()
// Calculate the transformed x and y coordinates
- let bx = string.includes('left') ? x
+ const bx = string.includes('left') ? x
: string.includes('right') ? x + width
: x + width / 2
- let by = string.includes('top') ? y
+ const by = string.includes('top') ? y
: string.includes('bottom') ? y + height
: y + height / 2