🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

grunt-svgstore

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-svgstore - npm Package Compare versions

Comparing version

to
0.3.1

7

Gruntfile.js

@@ -117,3 +117,3 @@ /*

options: {
cleanup: true,
cleanup: ['style', 'id'],
cleanupdefs: true

@@ -146,3 +146,3 @@ },

options: {
cleanup: ['style'],
cleanup: ['style', 'id'],
cleanupdefs: true

@@ -156,2 +156,5 @@ },

removeemptyg: {
options: {
cleanup: ['id']
},
files: {

@@ -158,0 +161,0 @@ 'tmp/no_empty_g.svg': ['test/fixtures/scissors.svg']

{
"name": "grunt-svgstore",
"description": "Merge SVGs from a folder.",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/FWeinb/grunt-svgstore",

@@ -6,0 +6,0 @@ "author": {

@@ -6,3 +6,3 @@ # grunt-svgstore [![NPM version](https://badge.fury.io/js/grunt-svgstore.svg)](http://badge.fury.io/js/grunt-svgstore) [![Build Status](https://travis-ci.org/FWeinb/grunt-svgstore.svg?branch=master)](https://travis-ci.org/FWeinb/grunt-svgstore)

## Why?
Because [Chris Coyer](http://shoptalkshow.com/episodes/103-louis-lazaris/#t=33:52) asked.
Because [Chris Coyier](http://shoptalkshow.com/episodes/103-louis-lazaris/#t=33:52) asked.

@@ -113,3 +113,3 @@ ## Getting Started

When set to false, no cleanup is performed on the <defs> element. (#41)
When set to false, no cleanup is performed on the `<defs>` element.

@@ -148,9 +148,12 @@

#### 0.3.1
* Fix removal of unreferenced IDs (See [#46](https://github.com/FWeinb/grunt-svgstore/issues/46))
#### 0.3.0
* Changed the way ID are collected; unreferenced IDs are removed now in order to save space. ([#40](https://github.com/FWeinb/grunt-svgstore/pull/40))
* Changed the way ID are collected; <del>unreferenced IDs are removed now in order to save space.</del> ([#40](https://github.com/FWeinb/grunt-svgstore/pull/40))
* Changed the behavior of the 'cleanup'-option (introduced in 0.2.6). Apart from true / false, the value of this property can now be an array of attributes. All attributes in the array are removed from all elements in the SVG. ([#41](https://github.com/FWeinb/grunt-svgstore/pull/41))
* Added an option 'cleanupdefs' (default: false). When set to false, no cleanup is performed on the <defs> element. ([#41](https://github.com/FWeinb/grunt-svgstore/pull/41))
* Empty g elements are removed since they have no effect in a document. ([#42](https://github.com/FWeinb/grunt-svgstore/pull/42))
* Added an option 'cleanupdefs' (default: false). When set to false, no cleanup is performed on the `<defs>` element. ([#41](https://github.com/FWeinb/grunt-svgstore/pull/41))
* Empty `<g>` elements are removed since they have no effect in a document. ([#42](https://github.com/FWeinb/grunt-svgstore/pull/42))

@@ -157,0 +160,0 @@ Thanks to [Frank3K](https://github.com/Frank3K) for the PRs

@@ -94,5 +94,13 @@ /*

// Map to store references from id to uniqueId + id;
// N.B.: only IDs that are referenced are mapped.
var mappedIds = {};
var uniqueId;
function getUniqueId(oldId) {
if (!uniqueId) {
uniqueId = md5(contentStr);
}
return 'svgstore' + uniqueId + oldId;
}
$('*').each(function () {

@@ -107,9 +115,5 @@ var $elem = $(this);

// Add id mapping if not already present
// Add ID mapping if not already present
if (!mappedIds[refId]) {
if (!uniqueId) {
uniqueId = md5(contentStr);
}
var newId = 'svgstore' + uniqueId + refId;
mappedIds[refId] = newId;
mappedIds[refId] = getUniqueId(refId);
}

@@ -120,5 +124,8 @@

if (options.cleanupdefs || !$elem.parents('defs').length) {
if (cleanupAttributes.indexOf(key) > -1){
$elem.removeAttr(key);
// IDs are handled separately
if (key !== 'id') {
if (options.cleanupdefs || !$elem.parents('defs').length) {
if (cleanupAttributes.indexOf(key) > -1){
$elem.removeAttr(key);
}
}

@@ -134,6 +141,10 @@ }

var newId = mappedIds[id];
if (!newId) {
if (!newId && cleanupAttributes.indexOf('id') > -1) {
// ID is not refenced and can therefore be removed
$elem.removeAttr('id');
} else {
if (!newId) {
mappedIds[id] = newId = getUniqueId(id);
}
// Replace id by mapped id

@@ -140,0 +151,0 @@ $elem.attr('id', newId);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet