From b9bf614f6c55069e03d1c90fe9d5c269164a01aa Mon Sep 17 00:00:00 2001 From: nex3 Date: Fri, 7 Dec 2007 20:09:16 +0000 Subject: [PATCH] Allow loud comments to appear beneath nested attributes. Thanks to Hrvoje Marjanovic for pointing this out. git-svn-id: svn://hamptoncatlin.com/haml/trunk@683 7063305b-7217-0410-af8c-cdc13e5119b9 --- lib/sass/tree/attr_node.rb | 2 +- lib/sass/tree/comment_node.rb | 2 +- test/sass/results/complex.css | 2 +- test/sass/templates/complex.sass | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sass/tree/attr_node.rb b/lib/sass/tree/attr_node.rb index aca1b725..811a182a 100644 --- a/lib/sass/tree/attr_node.rb +++ b/lib/sass/tree/attr_node.rb @@ -45,7 +45,7 @@ module Sass::Tree end def invalid_child?(child) - if !child.is_a?(AttrNode) + if !child.is_a?(AttrNode) && !child.is_a?(CommentNode) "Illegal nesting: Only attributes may be nested beneath attributes." end end diff --git a/lib/sass/tree/comment_node.rb b/lib/sass/tree/comment_node.rb index 06f84bdc..8b6639e9 100644 --- a/lib/sass/tree/comment_node.rb +++ b/lib/sass/tree/comment_node.rb @@ -6,7 +6,7 @@ module Sass::Tree super(value[2..-1].strip, style) end - def to_s(parent_name = nil) + def to_s(tabs = 0, parent_name = nil) unless @style == :compressed join_string = @style == :compact ? ' ' : "\n * " "/* #{value}#{join_string unless children.empty?}#{children.join join_string} */" diff --git a/test/sass/results/complex.css b/test/sass/results/complex.css index 6b3123b1..6a0fee6b 100644 --- a/test/sass/results/complex.css +++ b/test/sass/results/complex.css @@ -3,7 +3,7 @@ body { margin: 0; font: 0.85em "Lucida Grande", "Trebuchet MS", Verdana, sans-se #page { width: 900px; margin: 0 auto; background: #440008; border-top-width: 5px; border-top-style: solid; border-top-color: #ff8500; } #header { height: 75px; padding: 0; } -#header h1 { float: left; width: 274px; height: 75px; margin: 0; background-image: url(/images/global_logo.gif); background-repeat: no-repeat; text-indent: -9999px; } +#header h1 { float: left; width: 274px; height: 75px; margin: 0; background-image: url(/images/global_logo.gif); /* Crazy nested comment */ background-repeat: no-repeat; text-indent: -9999px; } #header .status { float: right; padding-top: .5em; padding-left: .5em; padding-right: .5em; padding-bottom: 0; } #header .status p { float: left; margin-top: 0; margin-right: 0.5em; margin-bottom: 0; margin-left: 0; } #header .status ul { float: left; margin: 0; padding: 0; } diff --git a/test/sass/templates/complex.sass b/test/sass/templates/complex.sass index 65178154..44c2f849 100644 --- a/test/sass/templates/complex.sass +++ b/test/sass/templates/complex.sass @@ -23,6 +23,7 @@ body :margin 0 :background :image url(/images/global_logo.gif) + /* Crazy nested comment :repeat no-repeat :text-indent -9999px .status