Socket
Socket
Sign inDemoInstall

svgo

Package Overview
Dependencies
23
Maintainers
3
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.3 to 2.1.0

5

lib/svgo-node.js

@@ -12,7 +12,2 @@ 'use strict';

const importConfig = async configFile => {
try {
await fs.promises.access(configFile);
} catch {
return null;
}
const config = require(configFile);

@@ -19,0 +14,0 @@ if (config == null || typeof config !== 'object' || Array.isArray(config)) {

2

lib/svgo/coa.js

@@ -37,3 +37,3 @@ 'use strict';

.option('-p, --precision <INTEGER>', 'Set number of digits in the fractional part, overrides plugins params')
.option('--config <CONFIG>', 'Config file or JSON string to extend or replace default')
.option('--config <CONFIG>', 'Custom config file, only .js is supported')
.option('--datauri <FORMAT>', 'Output as Data URI string (base64), URI encoded (enc) or unencoded (unenc)')

@@ -40,0 +40,0 @@ .option('--multipass', 'Pass over SVGs multiple times to ensure all optimizations are applied')

'use strict';
var EOL = require('os').EOL,
textElem = require('../../plugins/_collections.js').elemsGroups.textContent.concat('title');
textElems = require('../../plugins/_collections.js').textElems;

@@ -261,3 +261,3 @@ var defaults = {

openIndent = this.createIndent(),
textIndent = '',
closeIndent = this.createIndent(),
processedData = '',

@@ -272,6 +272,6 @@ dataEnd = '';

openIndent = '';
} else if (data.isElem(textElem)) {
if (this.config.pretty) {
textIndent += openIndent + this.config.indent;
}
} else if (data.isElem(textElems)) {
tagOpenEnd = defaults.tagOpenEnd;
tagCloseStart = defaults.tagCloseStart;
closeIndent = '';
this.textContext = data;

@@ -284,3 +284,2 @@ }

this.textContext = null;
if (this.config.pretty) dataEnd = EOL;
}

@@ -293,6 +292,5 @@

tagOpenEnd +
textIndent +
processedData +
dataEnd +
this.createIndent() +
closeIndent +
tagCloseStart +

@@ -299,0 +297,0 @@ data.elem +

'use strict';
var SAX = require('sax'),
var SAX = require('@trysound/sax'),
JSAPI = require('./jsAPI.js'),
CSSClassList = require('./css-class-list'),
CSSStyleDeclaration = require('./css-style-declaration'),
textElems = require('../../plugins/_collections.js').textElems,
entityDeclaration = /<!ENTITY\s+(\S+)\s+(?:'([^']+)'|"([^"]+)")\s*>/g;

@@ -12,3 +13,3 @@

trim: false,
normalize: true,
normalize: false,
lowercase: true,

@@ -29,4 +30,3 @@ xmlns: true,

current = root,
stack = [root],
textContext = null;
stack = [root];

@@ -120,7 +120,2 @@ function pushToContent(content) {

// Save info about <text> tag to prevent trimming of meaningful whitespace
if (data.name == 'text' && !data.prefix) {
textContext = current;
}
stack.push(elem);

@@ -131,27 +126,13 @@

sax.ontext = function(text) {
if (/\S/.test(text) || textContext) {
if (!textContext)
text = text.trim();
pushToContent({
text: text
});
}
// prevent trimming of meaningful whitespace inside textual tags
if (textElems.includes(current.elem) && !data.prefix) {
pushToContent({ text: text });
} else if (/\S/.test(text)) {
pushToContent({ text: text.trim() });
}
};
sax.onclosetag = function() {
var last = stack.pop();
// Trim text inside <text> tag.
if (last == textContext) {
trim(textContext);
textContext = null;
}
current = stack[stack.length - 1];
stack.pop();
current = stack[stack.length - 1];
};

@@ -175,18 +156,2 @@

function trim(elem) {
if (!elem.content) return elem;
var start = elem.content[0],
end = elem.content[elem.content.length - 1];
while (start && start.content && !start.text) start = start.content[0];
if (start && start.text) start.text = start.text.replace(/^\s+/, '');
while (end && end.content && !end.text) end = end.content[end.content.length - 1];
if (end && end.text) end.text = end.text.replace(/\s+$/, '');
return elem;
}
};
{
"name": "svgo",
"version": "2.0.3",
"version": "2.1.0",
"description": "Nodejs-based tool for optimizing SVG vector graphics files",

@@ -92,2 +92,3 @@ "keywords": [

"dependencies": {
"@trysound/sax": "0.1.1",
"chalk": "^4.1.0",

@@ -99,3 +100,2 @@ "commander": "^7.1.0",

"csso": "^4.2.0",
"sax": "~1.2.4",
"stable": "^0.1.8"

@@ -102,0 +102,0 @@ },

@@ -18,2 +18,4 @@ 'use strict';

exports.textElems = exports.elemsGroups.textContent.concat('title');
exports.pathElems = ['path', 'glyph', 'missing-glyph'];

@@ -102,3 +104,3 @@

exports.attrsGroupsDefaults = {
core: {'xml:space': 'preserve'},
core: {'xml:space': 'default'},
filterPrimitive: {x: '0', y: '0', width: '100%', height: '100%'},

@@ -105,0 +107,0 @@ presentation: {

@@ -68,3 +68,3 @@ 'use strict';

// Don't remove IDs if the whole SVG consists only of defs.
if (item.isElem('svg')) {
if (item.isElem('svg') && item.content) {
var hasDefsOnly = true;

@@ -71,0 +71,0 @@

@@ -5,3 +5,3 @@ 'use strict';

exports.active = true;
exports.active = false;

@@ -8,0 +8,0 @@ exports.description = 'converts style to attributes';

@@ -239,4 +239,2 @@ 'use strict';

i -= 2;
transform = transforms[i];
}

@@ -243,0 +241,0 @@

@@ -28,6 +28,11 @@ 'use strict';

exports.fn = function(item) {
return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() &&
(!item.isElem('pattern') || !item.hasAttrLocal('href')));
return (
item.isElem(container) === false ||
item.isEmpty() === false ||
item.isElem('svg') ||
(item.isElem('pattern') && item.hasAttrLocal('href')) ||
// The 'g' may not have content, but the filter may cause a rectangle
// to be created and filled with pattern.
(item.isElem('g') && item.hasAttr('filter'))
);
};

@@ -15,3 +15,3 @@ <img src="https://svg.github.io/svgo-logo.svg" width="200" height="200" alt="logo"/>

```sh
npm -g svgo
npm -g install svgo
```

@@ -18,0 +18,0 @@ or

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc