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
|
@ -121,6 +121,7 @@ module Sass
|
||||||
expand_commas root
|
expand_commas root
|
||||||
nest_rules root
|
nest_rules root
|
||||||
flatten_rules root
|
flatten_rules root
|
||||||
|
fold_commas root
|
||||||
root
|
root
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -284,5 +285,36 @@ module Sass
|
||||||
|
|
||||||
flatten_rules(rule)
|
flatten_rules(rule)
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue