diff --git a/lib/sass/tree/attr_node.rb b/lib/sass/tree/attr_node.rb index 9db036aa..1b9ab3e8 100644 --- a/lib/sass/tree/attr_node.rb +++ b/lib/sass/tree/attr_node.rb @@ -10,6 +10,9 @@ module Sass::Tree end def to_s(parent_name = nil) + if name[-1] == ?: || value[-1] == ?; + raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump} (This isn't CSS!)", @line) + end real_name = name real_name = "#{parent_name}-#{real_name}" if parent_name if children.size > 0 @@ -18,11 +21,17 @@ module Sass::Tree to_return[0...-1] else if value.length < 1 - raise Sass::SyntaxError.new("Invalid attribute: \":#{name} #{value}\"", @line) + raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump}", @line) end "#{real_name}: #{value};" end end + + private + + def declaration + ":#{name} #{value}" + end end end diff --git a/test/sass/engine_test.rb b/test/sass/engine_test.rb index 430e2072..361cd246 100644 --- a/test/sass/engine_test.rb +++ b/test/sass/engine_test.rb @@ -22,6 +22,8 @@ class SassEngineTest < Test::Unit::TestCase ": a" => 'Invalid attribute: ": a"', ":= a" => 'Invalid attribute: ":= a"', "a\n :b" => 'Invalid attribute: ":b "', + "a\n :b: c" => 'Invalid attribute: ":b: c" (This isn\'t CSS!)', + "a\n :b c;" => 'Invalid attribute: ":b c;" (This isn\'t CSS!)', ":a" => 'Attributes aren\'t allowed at the root of a document.', "!" => 'Invalid constant: "!"', "!a" => 'Invalid constant: "!a"', diff --git a/test/sass/results/complex.css b/test/sass/results/complex.css index 21fe19e1..5c9c231c 100644 --- a/test/sass/results/complex.css +++ b/test/sass/results/complex.css @@ -12,9 +12,9 @@ body { margin: 0; font: 0.85em "Lucida Grande", "Trebuchet MS", Verdana, sans-se #header .status a:hover { text-decoration: underline; } #header .search { float: right; clear: right; margin: 12px 0 0 0; } #header .search form { margin: 0; } -#header .search input { margin: 0 3px 0 0; padding:: 2px; border:: none; } +#header .search input { margin: 0 3px 0 0; padding: 2px; border: none; } -#menu { clear: both; text-align: right; height: 20px; border-bottom: 5px solid #006b95; background:: #00a4e4; } +#menu { clear: both; text-align: right; height: 20px; border-bottom: 5px solid #006b95; background: #00a4e4; } #menu .contests ul { margin: 0 5px 0 0; padding: 0; } #menu .contests ul li { list-style-type: none; margin: 0 5px; padding: 5px 5px 0 5px; display: inline; font-size: 1.1em; color: #fff; background: #00a4e4; } #menu .contests a:link, #menu .contests a:visited { color: #fff; text-decoration: none; font-weight: bold; } diff --git a/test/sass/templates/complex.sass b/test/sass/templates/complex.sass index b0c29549..0b806be9 100644 --- a/test/sass/templates/complex.sass +++ b/test/sass/templates/complex.sass @@ -60,15 +60,15 @@ body :margin 0 input :margin 0 3px 0 0 - :padding: 2px - :border: none + :padding 2px + :border none #menu :clear both :text-align right :height 20px :border-bottom 5px solid #006b95 - :background: #00a4e4 + :background #00a4e4 .contests ul :margin 0 5px 0 0