Accidental CSS-like attributes now throw errors.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@342 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-02-04 05:37:27 +00:00
parent 4058e4d147
commit 0840be5e24
4 changed files with 17 additions and 6 deletions

View File

@ -10,6 +10,9 @@ module Sass::Tree
end end
def to_s(parent_name = nil) 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 = name
real_name = "#{parent_name}-#{real_name}" if parent_name real_name = "#{parent_name}-#{real_name}" if parent_name
if children.size > 0 if children.size > 0
@ -18,11 +21,17 @@ module Sass::Tree
to_return[0...-1] to_return[0...-1]
else else
if value.length < 1 if value.length < 1
raise Sass::SyntaxError.new("Invalid attribute: \":#{name} #{value}\"", @line) raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump}", @line)
end end
"#{real_name}: #{value};" "#{real_name}: #{value};"
end end
end end
private
def declaration
":#{name} #{value}"
end
end end
end end

View File

@ -22,6 +22,8 @@ class SassEngineTest < Test::Unit::TestCase
": a" => 'Invalid attribute: ": a"', ": a" => 'Invalid attribute: ": a"',
":= a" => 'Invalid attribute: ":= a"', ":= a" => 'Invalid attribute: ":= a"',
"a\n :b" => 'Invalid attribute: ":b "', "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.', ":a" => 'Attributes aren\'t allowed at the root of a document.',
"!" => 'Invalid constant: "!"', "!" => 'Invalid constant: "!"',
"!a" => 'Invalid constant: "!a"', "!a" => 'Invalid constant: "!a"',

View File

@ -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 .status a:hover { text-decoration: underline; }
#header .search { float: right; clear: right; margin: 12px 0 0 0; } #header .search { float: right; clear: right; margin: 12px 0 0 0; }
#header .search form { margin: 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 { 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 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; } #menu .contests a:link, #menu .contests a:visited { color: #fff; text-decoration: none; font-weight: bold; }

View File

@ -60,15 +60,15 @@ body
:margin 0 :margin 0
input input
:margin 0 3px 0 0 :margin 0 3px 0 0
:padding: 2px :padding 2px
:border: none :border none
#menu #menu
:clear both :clear both
:text-align right :text-align right
:height 20px :height 20px
:border-bottom 5px solid #006b95 :border-bottom 5px solid #006b95
:background: #00a4e4 :background #00a4e4
.contests .contests
ul ul
:margin 0 5px 0 0 :margin 0 5px 0 0