diff options
Diffstat (limited to 'src/elements')
-rw-r--r-- | src/elements/A.js | 10 | ||||
-rw-r--r-- | src/elements/Dom.js | 14 | ||||
-rw-r--r-- | src/elements/Ellipse.js | 2 | ||||
-rw-r--r-- | src/elements/Image.js | 4 | ||||
-rw-r--r-- | src/elements/Line.js | 2 | ||||
-rw-r--r-- | src/elements/Marker.js | 2 | ||||
-rw-r--r-- | src/elements/Mask.js | 2 | ||||
-rw-r--r-- | src/elements/Path.js | 5 | ||||
-rw-r--r-- | src/elements/Style.js | 4 | ||||
-rw-r--r-- | src/elements/Text.js | 18 | ||||
-rw-r--r-- | src/elements/TextPath.js | 8 | ||||
-rw-r--r-- | src/elements/Tspan.js | 10 |
12 files changed, 40 insertions, 41 deletions
diff --git a/src/elements/A.js b/src/elements/A.js index 478c36d..173fc92 100644 --- a/src/elements/A.js +++ b/src/elements/A.js @@ -32,17 +32,17 @@ registerMethods({ }, Element: { unlink () { - var link = this.linker() + const link = this.linker() if (!link) return this - var parent = link.parent() + const parent = link.parent() if (!parent) { return this.remove() } - var index = parent.index(link) + const index = parent.index(link) parent.add(this, index) link.remove() @@ -50,7 +50,7 @@ registerMethods({ }, linkTo (url) { // reuse old link if possible - var link = this.linker() + let link = this.linker() if (!link) { link = new A() @@ -66,7 +66,7 @@ registerMethods({ return this }, linker () { - var link = this.parent() + const link = this.parent() if (link && link.node.nodeName.toLowerCase() === 'a') { return link } diff --git a/src/elements/Dom.js b/src/elements/Dom.js index c874353..e127f8c 100644 --- a/src/elements/Dom.js +++ b/src/elements/Dom.js @@ -77,8 +77,8 @@ export default class Dom extends EventTarget { // Iterates over all children and invokes a given block each (block, deep) { - var children = this.children() - var i, il + const children = this.children() + let i, il for (i = 0, il = children.length; i < il; i++) { block.apply(children[i], [ i, children ]) @@ -152,7 +152,7 @@ export default class Dom extends EventTarget { // Returns the parent element instance parent (type) { - var parent = this + let parent = this // check for parent if (!parent.node.parentNode) return null @@ -262,8 +262,6 @@ export default class Dom extends EventTarget { // Import / Export raw svg xml (xmlOrFn, outerXML, ns) { - var well, len, fragment - if (typeof xmlOrFn === 'boolean') { ns = outerXML outerXML = xmlOrFn @@ -320,14 +318,14 @@ export default class Dom extends EventTarget { outerXML = outerXML == null ? false : outerXML // Create temporary holder - well = create('wrapper', ns) - fragment = globals.document.createDocumentFragment() + const well = create('wrapper', ns) + const fragment = globals.document.createDocumentFragment() // Dump raw svg well.innerHTML = xmlOrFn // Transplant nodes into the fragment - for (len = well.children.length; len--;) { + for (let len = well.children.length; len--;) { fragment.appendChild(well.firstElementChild) } diff --git a/src/elements/Ellipse.js b/src/elements/Ellipse.js index b993687..7f4e853 100644 --- a/src/elements/Ellipse.js +++ b/src/elements/Ellipse.js @@ -16,7 +16,7 @@ export default class Ellipse extends Shape { } size (width, height) { - var p = proportionalSize(this, width, height) + const p = proportionalSize(this, width, height) return this .rx(new SVGNumber(p.width).divide(2)) diff --git a/src/elements/Image.js b/src/elements/Image.js index 347269c..c51bc9a 100644 --- a/src/elements/Image.js +++ b/src/elements/Image.js @@ -17,10 +17,10 @@ export default class Image extends Shape { load (url, callback) { if (!url) return this - var img = new globals.window.Image() + const img = new globals.window.Image() on(img, 'load', function (e) { - var p = this.parent(Pattern) + const p = this.parent(Pattern) // ensure image size if (this.width() === 0 && this.height() === 0) { diff --git a/src/elements/Line.js b/src/elements/Line.js index 1b72a7d..9350a23 100644 --- a/src/elements/Line.js +++ b/src/elements/Line.js @@ -44,7 +44,7 @@ export default class Line extends Shape { // Set element size to given width and height size (width, height) { - var p = proportionalSize(this, width, height) + const p = proportionalSize(this, width, height) return this.attr(this.array().size(p.width, p.height).toLine()) } } diff --git a/src/elements/Marker.js b/src/elements/Marker.js index 56ac3e8..d6f98c8 100644 --- a/src/elements/Marker.js +++ b/src/elements/Marker.js @@ -69,7 +69,7 @@ registerMethods({ marker: { // Create and attach markers marker (marker, width, height, block) { - var attr = [ 'marker' ] + let attr = [ 'marker' ] // Build attribute name if (marker !== 'all') attr.push(marker) diff --git a/src/elements/Mask.js b/src/elements/Mask.js index 3d2119e..e43d83f 100644 --- a/src/elements/Mask.js +++ b/src/elements/Mask.js @@ -39,7 +39,7 @@ registerMethods({ maskWith (element) { // use given mask or create a new one - var masker = element instanceof Mask + const masker = element instanceof Mask ? element : this.parent().mask().add(element) diff --git a/src/elements/Path.js b/src/elements/Path.js index ae2fac6..2aa0a51 100644 --- a/src/elements/Path.js +++ b/src/elements/Path.js @@ -33,13 +33,14 @@ export default class Path extends Shape { // Plot new path plot (d) { - return (d == null) ? this.array() + return (d == null) + ? this.array() : this.clear().attr('d', typeof d === 'string' ? d : (this._array = new PathArray(d))) } // Set element size to given width and height size (width, height) { - var p = proportionalSize(this, width, height) + const p = proportionalSize(this, width, height) return this.attr('d', this.array().size(p.width, p.height)) } diff --git a/src/elements/Style.js b/src/elements/Style.js index 62467d8..f7c3c57 100644 --- a/src/elements/Style.js +++ b/src/elements/Style.js @@ -7,9 +7,9 @@ function cssRule (selector, rule) { if (!selector) return '' if (!rule) return selector - var ret = selector + '{' + let ret = selector + '{' - for (var i in rule) { + for (const i in rule) { ret += unCamelCase(i) + ':' + rule[i] + ';' } diff --git a/src/elements/Text.js b/src/elements/Text.js index cc8db4a..f716f83 100644 --- a/src/elements/Text.js +++ b/src/elements/Text.js @@ -43,15 +43,15 @@ export default class Text extends Shape { // define position of all lines if (this._rebuild) { - var self = this - var blankLineOffset = 0 - var leading = this.dom.leading + const self = this + let blankLineOffset = 0 + const leading = this.dom.leading this.each(function (i) { - var fontSize = globals.window.getComputedStyle(this.node) + const fontSize = globals.window.getComputedStyle(this.node) .getPropertyValue('font-size') - var dy = leading * new SVGNumber(fontSize) + const dy = leading * new SVGNumber(fontSize) if (this.dom.newLined) { this.attr('x', self.attr('x')) @@ -82,11 +82,11 @@ export default class Text extends Shape { text (text) { // act as getter if (text === undefined) { - var children = this.node.childNodes - var firstLine = 0 + const children = this.node.childNodes + let firstLine = 0 text = '' - for (var i = 0, len = children.length; i < len; ++i) { + for (let i = 0, len = children.length; i < len; ++i) { // skip textPaths - they are no lines if (children[i].nodeName === 'textPath') { if (i === 0) firstLine = 1 @@ -116,7 +116,7 @@ export default class Text extends Shape { text = (text + '').split('\n') // build new lines - for (var j = 0, jl = text.length; j < jl; j++) { + for (let j = 0, jl = text.length; j < jl; j++) { this.newLine(text[j]) } } diff --git a/src/elements/TextPath.js b/src/elements/TextPath.js index edac399..2a17854 100644 --- a/src/elements/TextPath.js +++ b/src/elements/TextPath.js @@ -14,15 +14,15 @@ export default class TextPath extends Text { // return the array of the path track element array () { - var track = this.track() + const track = this.track() return track ? track.array() : null } // Plot path if any plot (d) { - var track = this.track() - var pathArray = null + const track = this.track() + let pathArray = null if (track) { pathArray = track.plot(d) @@ -51,7 +51,7 @@ registerMethods({ Text: { // Create path for text to run on path: wrapWithAttrCheck(function (track, importNodes = true) { - var textPath = new TextPath() + const textPath = new TextPath() // if track is a path, reuse it if (!(track instanceof Path)) { diff --git a/src/elements/Tspan.js b/src/elements/Tspan.js index 59860f7..73cd52d 100644 --- a/src/elements/Tspan.js +++ b/src/elements/Tspan.js @@ -34,18 +34,18 @@ export default class Tspan extends Shape { this.dom.newLined = true // fetch parent - var text = this.parent() + const text = this.parent() // early return in case we are not in a text element if (!(text instanceof Text)) { return this } - var i = text.index(this) + const i = text.index(this) - var fontSize = globals.window.getComputedStyle(this.node) + const fontSize = globals.window.getComputedStyle(this.node) .getPropertyValue('font-size') - var dy = text.dom.leading * new SVGNumber(fontSize) + const dy = text.dom.leading * new SVGNumber(fontSize) // apply new position return this.dy(i ? dy : 0).attr('x', text.x()) @@ -73,7 +73,7 @@ extend(Tspan, textable) registerMethods({ Tspan: { tspan: wrapWithAttrCheck(function (text = '') { - var tspan = new Tspan() + const tspan = new Tspan() // clear if build mode is disabled if (!this._build) { |