Non-attributes nested beneath attributes throw errors.

git-svn-id: svn://hamptoncatlin.com/haml/trunk@436 7063305b-7217-0410-af8c-cdc13e5119b9
This commit is contained in:
nex3 2007-03-18 04:15:50 +00:00
parent 432f841d30
commit 8baa674092
3 changed files with 20 additions and 1 deletions

View File

@ -40,5 +40,11 @@ module Sass::Tree
def declaration
":#{name} #{value}"
end
def invalid_child?(child)
if !child.is_a?(AttrNode)
"Illegal nesting: Only attributes may be nested beneath attributes."
end
end
end
end

View File

@ -10,6 +10,9 @@ module Sass
end
def <<(child)
if msg = invalid_child?(child)
raise Sass::SyntaxError.new(msg, child.line)
end
@children << child
end
@ -24,6 +27,15 @@ module Sass
end
result[0...-1]
end
private
# This method should be overridden by subclasses to return an error message
# if the given child node is invalid,
# and false or nil otherwise.
def invalid_child?(child)
false
end
end
end
end

View File

@ -33,7 +33,8 @@ class SassEngineTest < Test::Unit::TestCase
"a\n :b c" => "Illegal Indentation: Only two space characters are allowed as tabulation.",
"a\n :b c\n !d = 3" => "Constants may only be declared at the root of a document.",
"!a = 1b + 2c" => "Incompatible units: b and c",
"& a\n :b c" => "Base-level rules cannot contain the parent-selector-referencing character '&'"
"& a\n :b c" => "Base-level rules cannot contain the parent-selector-referencing character '&'",
"a\n :b\n c" => "Illegal nesting: Only attributes may be nested beneath attributes."
}
def test_basic_render