class Sanitize::Transformers::CSS::CleanAttribute

Enforces a CSS whitelist on the contents of ‘style` attributes.

def call(env)

def call(env)
  node = env[:node]
  return unless node.type == Nokogiri::XML::Node::ELEMENT_NODE &&
      node.key?('style') && !env[:is_whitelisted]
  attr = node.attribute('style')
  css  = @scss.properties(attr.value)
  if css.strip.empty?
    attr.unlink
  else
    attr.value = css
  end
end

def initialize(sanitizer_or_config)

def initialize(sanitizer_or_config)
  if Sanitize::CSS === sanitizer_or_config
    @scss = sanitizer_or_config
  else
    @scss = Sanitize::CSS.new(sanitizer_or_config)
  end
end