public
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/nex3/haml.git
Search Repo:
Fix a css2sass bug.

Rule-flattening wasn't working quite properly.

    foo.bar { baz: boom }

would render as

    foo &.bar
      baz: boom
nex3 (author)
Tue Apr 29 15:09:07 -0700 2008
commit  0b1d5c48d9c55d7d2e7c7cbafc4512c01e1392fb
tree    d2073537e327607493b80af00cbbf4bee86599cb
parent  b05cafdf41c236014ae19977863da179a71dc3a0
...
313
314
315
 
 
 
 
 
 
 
 
 
 
 
316
317
318
...
320
321
322
323
 
 
 
 
 
 
 
324
325
326
...
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
331
332
333
 
334
335
336
337
338
339
340
341
342
343
0
@@ -313,6 +313,17 @@ module Sass
0
     # foo bar baz
0
     # color: red
0
     #
0
+ # and
0
+ #
0
+ # foo
0
+ # &.bar
0
+ # color: blue
0
+ #
0
+ # becomes
0
+ #
0
+ # foo.bar
0
+ # color: blue
0
+ #
0
     def flatten_rules(root)
0
       root.children.each { |child| flatten_rule(child) if child.is_a?(Tree::RuleNode) }
0
     end
0
@@ -320,7 +331,13 @@ module Sass
0
     def flatten_rule(rule)
0
       while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
0
         child = rule.children.first
0
- rule.rule = "#{rule.rule} #{child.rule}"
0
+
0
+ if child.rule[0] == ?&
0
+ rule.rule = child.rule.gsub /^&/, rule.rule
0
+ else
0
+ rule.rule = "#{rule.rule} #{child.rule}"
0
+ end
0
+
0
         rule.children = child.children
0
       end
0
 

Comments

    No one has commented yet.