class Sass::CSS

def fold_commas(root)

Parameters:
  • root (Tree::Node) -- The parent node
def fold_commas(root)
  prev_rule = nil
  root.children.map! do |child|
    unless child.is_a?(Tree::RuleNode)
      fold_commas(child) if child.is_a?(Tree::DirectiveNode)
      next child
    end
    if prev_rule && prev_rule.children.map {|c| c.to_sass} == child.children.map {|c| c.to_sass}
      prev_rule.parsed_rules.members << first_seq(child)
      next nil
    end
    fold_commas(child)
    prev_rule = child
    child
  end
  root.children.compact!
end