Class: SvgOptimizer::Plugins::RemoveUselessStrokeAndFill

Inherits:
Base
  • Object
show all
Defined in:
lib/svg_optimizer/plugins/remove_useless_stroke_and_fill.rb

Constant Summary collapse

SELECTOR =
%w[circle ellipse line path polygon polyline rect].join(",")
STROKE_ATTRS =
%w[
  stroke
  stroke-opacity
  stroke-width
  stroke-dashoffset
].freeze
FILL_ATTRS =
%w[fill-opacity fill-rule].freeze

Instance Attribute Summary

Attributes inherited from Base

#xml

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SvgOptimizer::Plugins::Base

Instance Method Details

#processObject



15
16
17
18
19
20
21
# File 'lib/svg_optimizer/plugins/remove_useless_stroke_and_fill.rb', line 15

def process
  return if xml.css("style, script").any?

  xml.css(SELECTOR).each do |node|
    remove_useless_attributes(node)
  end
end