Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svg-sprite

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svg-sprite - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 1.3.1 Bugfix release (2016-04-17)
* Fixed modeless run ([#158](https://github.com/jkphl/svg-sprite/issues/158), [gulp-svg-sprite #42](https://github.com/jkphl/gulp-svg-sprite/issues/42))
* Fixed broken shape dimension attribute removal in symbol mode ([gulp-svg-sprite #51](https://github.com/jkphl/gulp-svg-sprite/issues/51))
## 1.3.0 Major maintenance release (2016-04-14)

@@ -2,0 +6,0 @@ * Updated dependencies

@@ -116,2 +116,3 @@ svg-sprite [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency Status][depstat-image]][depstat-url] [![Development Dependency Status][devdepstat-image]][devdepstat-url]

`shape.dimension.precision` | Integer | `2` | Precision (number of decimal places) for dimension calculations |
`shape.dimension.attributes` | Boolean | `false` | Whether to add `width` and `height` attributes to embedded shapes («defs» and «stack» mode only) |

@@ -118,0 +119,0 @@

85

lib/svg-sprite.js

@@ -197,16 +197,5 @@ 'use strict';

// If there's a valid mode configuration
if (_.size(config)) {
this._compileQueue.push([config, cb]);
this._compile();
// Else: Error
} else {
var error = util.format('SVGSpriter.compile: "%s" is not a valid mode configuration', util.inspect(config)),
e = new Error(error);
e.name = 'ArgumentError';
e.errno = 1420362541;
this.error(error, e);
cb(e, null, null);
}
// Schedule a compilation run
this._compileQueue.push([config, cb]);
this._compile();
};

@@ -221,24 +210,9 @@

if (!this._queue.active && this._compileQueue.length) {
var masterShapes = _.reject(this._shapes, function(shape) { return !!shape.master; }).length;
this.info('Compiling %d shapes ...', masterShapes);
var that = this;
var args = this._compileQueue.shift();
var that = this,
args = this._compileQueue.shift();
// If this is a modeless run
if (args[0] === {}) {
var files = {};
// Initialize the namespace powers
while (!this._namespacePow.length || (Math.pow(26, this._namespacePow.length) < masterShapes)) {
this._namespacePow.unshift(Math.pow(26, this._namespacePow.length));
_.invoke(this._shapes, 'resetNamespace');
}
// Sort shapes by ID
this._shapes = this._shapes.sort(this.config.shape.sort);
// Set the shape namespaces on all master shapes
_.reject(this._shapes, function(shape) { return !!shape.master; }).map(function(shape, index){
shape.setNamespace(this._indexNamespace(index));
}, this);
this._layout(args[0], function(error, files, data) {
// Add intermediate SVG files

@@ -249,11 +223,42 @@ if (that.config.shape.dest) {

}
that.info('Finished %s sprite compilation', _.keys(data).map(function(mode){
return '«' + mode + '»';
}).join(' + '));
that._logStats(files);
args[1](null, files, {});
args[1](error, files, data);
that.emit('compiled');
});
// Else
} else {
var masterShapes = _.reject(this._shapes, function(shape) { return !!shape.master; }).length;
this.info('Compiling %d shapes ...', masterShapes);
// Initialize the namespace powers
while (!this._namespacePow.length || (Math.pow(26, this._namespacePow.length) < masterShapes)) {
this._namespacePow.unshift(Math.pow(26, this._namespacePow.length));
_.invoke(this._shapes, 'resetNamespace');
}
// Sort shapes by ID
this._shapes = this._shapes.sort(this.config.shape.sort);
// Set the shape namespaces on all master shapes
_.reject(this._shapes, function(shape) { return !!shape.master; }).map(function(shape, index){
shape.setNamespace(this._indexNamespace(index));
}, this);
this._layout(args[0], function(error, files, data) {
// Add intermediate SVG files
if (that.config.shape.dest) {
files.shapes = that._getShapeFiles(that.config.shape.dest);
that.verbose('Returning %d intermediate SVG files', files.shapes.length);
}
that.info('Finished %s sprite compilation', _.keys(data).map(function(mode){
return '«' + mode + '»';
}).join(' + '));
that._logStats(files);
args[1](error, files, data);
that.emit('compiled');
});
}
}

@@ -260,0 +265,0 @@ };

@@ -57,7 +57,11 @@ 'use strict';

shapeDOM.localName = 'symbol';
_.forIn(_.pick(shapeDOM.attributes, function(attribute) {
return symbolAttributes.indexOf(attribute.name) === -1;
}), function(attribute){
this.removeAttribute(attribute.name);
}, shapeDOM);
var removeAttributes = [];
Array.prototype.forEach.call(shapeDOM.attributes, function( attribute ){
if (symbolAttributes.indexOf(attribute.name) === -1) {
removeAttributes.push(attribute.name);
}
});
removeAttributes.forEach(function(attribute){
shapeDOM.removeAttribute(attribute);
})
shapeDOM.setAttribute('id', shape.id);

@@ -64,0 +68,0 @@ });

{
"name": "svg-sprite",
"version": "1.3.0",
"version": "1.3.1",
"author": "Joschi Kuphal <joschi@kuphal.net> (https://jkphl.is)",

@@ -5,0 +5,0 @@ "description": "SVG sprites & stacks galore — A low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites of several types along with suitable stylesheet resources (e.g. CSS, Sass, LESS, Stylus, etc.)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc