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

Disable removeUselessStrokeAndFill if there is a <style> or <script>

This commit is contained in:
GreLI
2015-03-29 21:27:52 +03:00
parent 00df0b369e
commit cf37722e29
2 changed files with 29 additions and 2 deletions

View File

@ -11,7 +11,9 @@ exports.params = {
var shape = require('./_collections').elemsGroups.shape,
regStrokeProps = /^stroke/,
regFillProps = /^fill-/;
regFillProps = /^fill-/,
styleOrScript = ['style', 'script'],
hasStyleOrScript = false;
/**
* Remove useless stroke and fill attrs.
@ -24,7 +26,11 @@ var shape = require('./_collections').elemsGroups.shape,
*/
exports.fn = function(item, params) {
if (item.isElem(shape) && !item.computedAttr('id')) {
if (item.isElem(styleOrScript)) {
hasStyleOrScript = true;
}
if (!hasStyleOrScript && item.isElem(shape) && !item.computedAttr('id')) {
var stroke = params.stroke && item.computedAttr('stroke'),
fill = params.fill && !item.computedAttr('fill', 'none');