Class: SvgOptimizer::Plugins::RemoveEmptyContainer

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

Constant Summary collapse

ELEMENTS =
%w[
  a
  defs
  g
  marker
  mask
  missing-glyph
  pattern
  switch
  symbol
].freeze
SELECTOR =
ELEMENTS.map {|element| %[#{element}:empty] }.join(", ")

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



19
20
21
22
23
# File 'lib/svg_optimizer/plugins/remove_empty_container.rb', line 19

def process
  while (nodes = xml.css(SELECTOR)).any?
    nodes.each(&method(:remove_node))
  end
end