1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-07 15:22:54 +03:00

Limited linking checks to referencing props

This commit is contained in:
GreLI
2015-01-25 20:00:40 +03:00
parent 35d351a15e
commit 290d610f27
2 changed files with 10 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ var regPathInstructions = /([MmLlHhVvCcSsQqTtAaZz])\s*/,
regNumericValues = /[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/,
transform2js = require('./_transforms').transform2js,
transformsMultiply = require('./_transforms').transformsMultiply,
referencesProps = require('./_collections.js').referencesProps,
cleanupOutData = require('../lib/svgo/tools').cleanupOutData,
removeLeadingZero = require('../lib/svgo/tools').removeLeadingZero;
@@ -190,7 +191,9 @@ exports.applyTransforms = function(elem, path, applyTransformsStroked, floatPrec
// if there are no 'stroke' attr and references to other objects such as
// gradiends or clip-path which are also subjects to transform.
if (!elem.hasAttr('transform') ||
elem.someAttr(function(attr) { return ~attr.value.indexOf('url(') }))
elem.someAttr(function(attr) {
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url(')
}))
return path;
var matrix = transformsMultiply(transform2js(elem.attr('transform').value)),

View File

@@ -4,7 +4,9 @@ exports.type = 'perItem';
exports.active = true;
var pathElems = require('./_collections.js').pathElems.slice();
var collections = require('./_collections.js'),
pathElems = collections.pathElems.slice(),
referencesProps = collections.referencesProps;
pathElems.push('g');
pathElems.push('text');
@@ -35,7 +37,9 @@ exports.fn = function(item) {
item.isElem('g') &&
item.hasAttr('transform') &&
!item.isEmpty() &&
!item.someAttr(function(attr) { return ~attr.value.indexOf('url(') }) &&
!item.someAttr(function(attr) {
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url(')
}) &&
item.content.every(function(inner) {
return inner.isElem(pathElems);
})