From 290d610f272032b3b0229d6d88ab4bc5825b4556 Mon Sep 17 00:00:00 2001 From: GreLI Date: Sun, 25 Jan 2015 20:00:40 +0300 Subject: [PATCH] Limited linking checks to referencing props --- plugins/_path.js | 5 ++++- plugins/moveGroupAttrsToElems.js | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/_path.js b/plugins/_path.js index 9b76937c..f32f1563 100644 --- a/plugins/_path.js +++ b/plugins/_path.js @@ -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)), diff --git a/plugins/moveGroupAttrsToElems.js b/plugins/moveGroupAttrsToElems.js index 627682e7..c22a2d8a 100644 --- a/plugins/moveGroupAttrsToElems.js +++ b/plugins/moveGroupAttrsToElems.js @@ -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); })