svgo
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -0,1 +1,8 @@ | ||
### [ [>](https://github.com/svg/svgo/tree/v0.4.4) ] 0.4.4 / 14.01.2014 | ||
* new plugin [plugins/removeTitle](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) (disabled by default, close [#159](https://github.com/svg/svgo/issues/159)) | ||
* plugins/convertPathData: skip data concatenation for z instruction in collapseRepeated | ||
* plugins/removeUnknownsAndDefaults: do not remove overriden attributes with default values (fix [#161](https://github.com/svg/svgo/issues/161) and [#168](https://github.com/svg/svgo/issues/168)) | ||
* plugins/removeViewBox: disable by default (fix [#139](https://github.com/svg/svgo/issues/139)) | ||
* update README with [gulp task](https://github.com/ben-eb/gulp-svgmin) | ||
### [ [>](https://github.com/svg/svgo/tree/v0.4.3) ] 0.4.3 / 02.01.2014 | ||
@@ -2,0 +9,0 @@ * new plugin [plugins/convertShapeToPath](https://github.com/svg/svgo/blob/master/plugins/convertShapeToPath.js) (close [#96](https://github.com/svg/svgo/issues/96)) |
{ | ||
"name": "svgo", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"description": "Nodejs-based tool for optimizing SVG vector graphics files", | ||
@@ -5,0 +5,0 @@ "keywords": [ "svgo", "svg", "optimize", "minify" ], |
@@ -496,6 +496,6 @@ 'use strict'; | ||
// increase previous h or v data with current | ||
if ((item.instruction === 'h' || item.instruction === 'v')&& (prev.data[0] >= 0) == (item.data[0] >= 0)) { | ||
if ((item.instruction === 'h' || item.instruction === 'v') && (prev.data[0] >= 0) == (item.data[0] >= 0)) { | ||
prev.data[0] += item.data[0]; | ||
// concat previous data with current | ||
} else { | ||
// concat previous data with current if it is not z | ||
} else if (item.instruction !== 'z') { | ||
prev.data = prev.data.concat(item.data); | ||
@@ -502,0 +502,0 @@ } |
@@ -11,3 +11,4 @@ 'use strict'; | ||
unknownAttrs: true, | ||
defaultAttrs: true | ||
defaultAttrs: true, | ||
uselessOverrides: true | ||
}; | ||
@@ -19,3 +20,4 @@ | ||
elemsGroups = collections.elemsGroups, | ||
attrsGroupsDefaults = collections.attrsGroupsDefaults; | ||
attrsGroupsDefaults = collections.attrsGroupsDefaults, | ||
attrsInheritable = collections.inheritableAttrs; | ||
@@ -66,2 +68,5 @@ // collect and extend all references | ||
var inheritable = { }, | ||
key, attr; | ||
// elems w/o namespace prefix | ||
@@ -105,9 +110,19 @@ if (item.isElem() && !item.prefix) { | ||
// unknown attrs | ||
(params.unknownAttrs && | ||
elems[elem].attrs.indexOf(attr.name) === -1) || | ||
( | ||
params.unknownAttrs && | ||
elems[elem].attrs.indexOf(attr.name) === -1 | ||
) || | ||
// attrs with default values | ||
(params.defaultAttrs && | ||
elems[elem].defaults && | ||
elems[elem].defaults[attr.name] === attr.value | ||
) | ||
( | ||
params.defaultAttrs && | ||
elems[elem].defaults && | ||
elems[elem].defaults[attr.name] === attr.value && | ||
(!item.inheritedAttrs || undefined === item.inheritedAttrs[attr.name]) | ||
) || | ||
// useless overrides | ||
( | ||
params.uselessOverrides && | ||
item.inheritedAttrs && | ||
item.inheritedAttrs[attr.name] === attr.value | ||
) | ||
) { | ||
@@ -122,4 +137,27 @@ item.removeAttr(attr.name); | ||
// mark overriden attributes for group content | ||
if (elem === 'g' && | ||
item.content | ||
) { | ||
if (item.inheritedAttrs) { | ||
for (key in item.inheritedAttrs) { | ||
inheritable[key] = item.inheritedAttrs[key]; | ||
} | ||
} | ||
item.eachAttr(function(attr) { | ||
if (attrsInheritable.indexOf(attr.name) >= 0) { | ||
inheritable[attr.name] = attr.value; | ||
} | ||
}); | ||
if (Object.keys(inheritable).length) { | ||
item.content.forEach(function(content, i) { | ||
content.inheritedAttrs = inheritable; | ||
} ); | ||
} | ||
} | ||
} | ||
}; |
@@ -5,3 +5,3 @@ 'use strict'; | ||
exports.active = true; | ||
exports.active = false; | ||
@@ -8,0 +8,0 @@ var regViewBox = /^0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/, |
@@ -26,2 +26,3 @@ **english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md) | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] remove `<metadata>` | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) ] remove `<title>` | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEditorsNSData.js) ] remove editors namespaces, elements and attributes | ||
@@ -119,9 +120,5 @@ * [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyAttrs.js) ] remove empty attributes | ||
* as a Grunt task – [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin) | ||
* as a Gulp task – [gulp-svgmin](https://github.com/ben-eb/gulp-svgmin) | ||
* as an OSX Folder Action – [svgo-osx-folder-action](https://github.com/svg/svgo-osx-folder-action) | ||
## TODO | ||
* [v0.3.x](https://github.com/svg/svgo/issues?milestone=7&state=open) | ||
## License and copyrights | ||
@@ -128,0 +125,0 @@ |
@@ -26,2 +26,3 @@ [english](https://github.com/svg/svgo/blob/master/README.md) | **русский** | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] удаление `<metadata>` | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) ] удаление `<title>` | ||
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEditorsNSData.js) ] удаление пространств имён различных редакторов, их элементов и атрибутов | ||
@@ -119,9 +120,5 @@ * [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyAttrs.js) ] удаление пустых атрибутов | ||
* как таск для Grunt – [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin) | ||
* как таск для Gulp – [gulp-svgmin](https://github.com/ben-eb/gulp-svgmin) | ||
* как действие папки в OSX – [svgo-osx-folder-action](https://github.com/svg/svgo-osx-folder-action) | ||
## TODO | ||
* [v0.3.x](https://github.com/svg/svgo/issues?milestone=7&state=open) | ||
## Лицензия и копирайты | ||
@@ -128,0 +125,0 @@ |
229484
51
6467
127