Skip to content

Commit

Permalink
Remove superfluous arguments passed to parseFloat and SVGShape.
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Feb 23, 2021
1 parent 358c4ad commit 8911752
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bin/svg-sprite.js
Expand Up @@ -199,7 +199,7 @@ if (argv['config']) {
// Refine particular config options
config.shape.spacing.padding = ('' + config.shape.spacing.padding).trim();
config.shape.spacing.padding = config.shape.spacing.padding.length ? config.shape.spacing.padding.split(',').map(function (dim) {
return parseFloat(dim || 0, 10);
return parseFloat(dim || 0);
}) : [];

if (config.svg.rootAttributes && typeof config.svg.rootAttributes === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion lib/svg-sprite/config.js
Expand Up @@ -170,7 +170,7 @@ function SVGSpriterConfig(config) {
this.shape.align[a] = this.shape.align[a] || {};
for (var tmpl in align[a]) {
var template = tmpl.length ? ((tmpl.indexOf('%s') >= 0) ? tmpl : ('%s' + tmpl)) : '%s';
this.shape.align[path.join(path.dirname(a), path.basename(a, '.svg'))][template] = Math.max(0, Math.min(1, parseFloat(align[a][tmpl], 10)));
this.shape.align[path.join(path.dirname(a), path.basename(a, '.svg'))][template] = Math.max(0, Math.min(1, parseFloat(align[a][tmpl])));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/svg-sprite/layouter.js
Expand Up @@ -63,7 +63,7 @@ defaultVariables = {
date : (new Date()).toGMTString(),
invert : function() {
return function(num, render) {
return -parseFloat(render(num), 10);
return -parseFloat(render(num));
};
},
classname : function() {
Expand Down
18 changes: 9 additions & 9 deletions lib/svg-sprite/shape.js
Expand Up @@ -363,11 +363,11 @@ SVGShape.prototype._initSVG = function() {

// Determine the shape width
var width = this.dom.documentElement.getAttribute('width');
this.width = width.length ? parseFloat(width, 10) : false;
this.width = width.length ? parseFloat(width) : false;

// Determine the shape height
var height = this.dom.documentElement.getAttribute('height');
this.height = height.length ? parseFloat(height, 10) : false;
this.height = height.length ? parseFloat(height) : false;

// Determine the viewbox
var viewBox = this.dom.documentElement.getAttribute('viewBox');
Expand All @@ -377,7 +377,7 @@ SVGShape.prototype._initSVG = function() {
viewBox.push(0);
}
viewBox.forEach(function(value, index) {
viewBox[index] = parseFloat(value, 10);
viewBox[index] = parseFloat(value);
});
this.viewBox = viewBox;
} else {
Expand Down Expand Up @@ -414,9 +414,9 @@ SVGShape.prototype.getDimensions = function() {
* @return {SVGShape} Self reference
*/
SVGShape.prototype.setDimensions = function(width, height) {
this.width = this._round(Math.max(0, parseFloat(width, 10)));
this.width = this._round(Math.max(0, parseFloat(width)));
this.dom.documentElement.setAttribute('width', this.width);
this.height = this._round(Math.max(0, parseFloat(height, 10)));
this.height = this._round(Math.max(0, parseFloat(height)));
this.dom.documentElement.setAttribute('height', this.height);
return this;
};
Expand Down Expand Up @@ -446,12 +446,12 @@ SVGShape.prototype.getViewbox = function(width, height) {
*/
SVGShape.prototype.setViewbox = function(x, y, width, height) {
if (Array.isArray(x)) {
this.viewBox = x.map(function(n) { return parseFloat(n, 10); });
this.viewBox = x.map(function(n) { return parseFloat(n); });
while (this.viewBox.length < 4) {
this.viewBox.push(0);
}
} else {
this.viewBox = [parseFloat(x, 10), parseFloat(y, 10), parseFloat(width, 10), parseFloat(height, 10)];
this.viewBox = [parseFloat(x), parseFloat(y), parseFloat(width), parseFloat(height)];
}
this.dom.documentElement.setAttribute('viewBox', this.viewBox.join(' '));
return this.viewBox;
Expand Down Expand Up @@ -892,6 +892,6 @@ SVGShape.prototype.distribute = function() {
* @param {Object} config SVG shape configuration
* @return {SVGShape} SVGShape instance
*/
module.exports = function(svg, name, file, config) {
return new SVGShape(svg, name, file, config || {});
module.exports = function(svg, name) {
return new SVGShape(svg, name);
};

0 comments on commit 8911752

Please sign in to comment.