mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Try to be better about preserving commas in css2sass.
git-svn-id: svn://hamptoncatlin.com/haml/trunk@702 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
parent
c882b2d332
commit
acda22070f
1 changed files with 32 additions and 0 deletions
|
@ -121,6 +121,7 @@ module Sass
|
|||
expand_commas root
|
||||
nest_rules root
|
||||
flatten_rules root
|
||||
fold_commas root
|
||||
root
|
||||
end
|
||||
|
||||
|
@ -284,5 +285,36 @@ module Sass
|
|||
|
||||
flatten_rules(rule)
|
||||
end
|
||||
|
||||
# Transform
|
||||
#
|
||||
# foo
|
||||
# bar
|
||||
# color: blue
|
||||
# baz
|
||||
# color: blue
|
||||
#
|
||||
# into
|
||||
#
|
||||
# foo
|
||||
# bar, baz
|
||||
# color: blue
|
||||
#
|
||||
def fold_commas(root)
|
||||
prev_rule = nil
|
||||
root.children.map! do |child|
|
||||
next child unless Tree::RuleNode === child
|
||||
|
||||
if prev_rule && prev_rule.children == child.children
|
||||
prev_rule.rule << ", #{child.rule}"
|
||||
next nil
|
||||
end
|
||||
|
||||
fold_commas(child)
|
||||
prev_rule = child
|
||||
child
|
||||
end
|
||||
root.children.compact!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue