Skip to content

Commit

Permalink
Disable removeUselessStrokeAndFill if there is a <style> or <script>
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Mar 29, 2015
1 parent 00df0b3 commit cf37722
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/removeUselessStrokeAndFill.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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');
Expand Down
21 changes: 21 additions & 0 deletions test/plugins/removeUselessStrokeAndFill.03.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cf37722

Please sign in to comment.