1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Fixing the rule flattening for css2sass.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@700 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-12-16 22:20:47 +00:00
parent 3b1df0b468
commit 0f41f43e76

View file

@ -244,13 +244,13 @@ module Sass
# color: red # color: red
# #
def flatten_rules(root) def flatten_rules(root)
root.children.each { |child| flatten_rules(child) if child.is_a?(Tree::RuleNode) } root.children.each { |child| flatten_rule(child) if child.is_a?(Tree::RuleNode) }
end end
def flatten_rule(rule) def flatten_rule(rule)
while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode) while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
child = rule.children.first child = rule.children.first
rule.rule = "#{root.rule} #{child.rule}" rule.rule = "#{rule.rule} #{child.rule}"
rule.children = child.children rule.children = child.children
end end