[Sass] Rename AttrNode to PropNode.

This commit is contained in:
Nathan Weizenbaum 2009-06-19 03:49:40 -07:00
parent 81900a6db5
commit 282009c85d
5 changed files with 12 additions and 12 deletions

View File

@ -24,7 +24,7 @@ module Sass
class RuleNode
# @see Node#to_sass
def to_sass(tabs, opts = {})
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? AttrNode } ? "\n" : ''}"
str = "\n#{' ' * tabs}#{rules.first}#{children.any? { |c| c.is_a? PropNode } ? "\n" : ''}"
children.each do |child|
str << "#{child.to_sass(tabs + 1, opts)}"
@ -34,7 +34,7 @@ module Sass
end
end
class AttrNode
class PropNode
# @see Node#to_sass
def to_sass(tabs, opts = {})
"#{' ' * tabs}#{opts[:old] ? ':' : ''}#{name}#{opts[:old] ? '' : ':'} #{value}\n"
@ -155,7 +155,7 @@ module Sass
end
assert_match /(;|(?=\}))/
rule << Tree::AttrNode.new(name, value, nil)
rule << Tree::PropNode.new(name, value, nil)
end
assert_match /\}/

View File

@ -3,7 +3,7 @@ require 'digest/sha1'
require 'sass/tree/node'
require 'sass/tree/rule_node'
require 'sass/tree/comment_node'
require 'sass/tree/attr_node'
require 'sass/tree/prop_node'
require 'sass/tree/directive_node'
require 'sass/tree/variable_node'
require 'sass/tree/mixin_def_node'
@ -335,7 +335,7 @@ END
else
value
end
Tree::AttrNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new)
Tree::PropNode.new(name, expr, property_regx == PROPERTY_OLD ? :old : :new)
end
def parse_variable(line)

View File

@ -41,7 +41,7 @@ module Sass::Tree
children.each do |child|
next if child.invisible?
if style == :compact
if child.is_a?(AttrNode)
if child.is_a?(PropNode)
result << "#{child.to_s(first || was_prop ? 1 : tabs + 1)} "
else
if was_prop
@ -51,11 +51,11 @@ module Sass::Tree
rendered.lstrip! if first
result << rendered
end
was_prop = child.is_a?(AttrNode)
was_prop = child.is_a?(PropNode)
first = false
elsif style == :compressed
result << (was_prop ? ";#{child.to_s(1)}" : child.to_s(1))
was_prop = child.is_a?(AttrNode)
was_prop = child.is_a?(PropNode)
else
result << child.to_s(tabs + 1) + "\n"
end

View File

@ -122,7 +122,7 @@ module Sass
def to_s
result = String.new
children.each do |child|
if child.is_a? AttrNode
if child.is_a? PropNode
raise Sass::SyntaxError.new('Properties aren\'t allowed at the root of a document.', child.line)
else
next if child.invisible?

View File

@ -2,7 +2,7 @@ module Sass::Tree
# A static node reprenting a CSS property.
#
# @see Sass::Tree
class AttrNode < Node
class PropNode < Node
# The name of the property.
#
# @return [String]
@ -91,11 +91,11 @@ module Sass::Tree
# Returns an error message if the given child node is invalid,
# and false otherwise.
#
# {AttrNode} only allows other {AttrNode}s and {CommentNode}s as children.
# {PropNode} only allows other {PropNode}s and {CommentNode}s as children.
# @param child [Tree::Node] A potential child node
# @return [String] An error message if the child is invalid, or nil otherwise
def invalid_child?(child)
if !child.is_a?(AttrNode) && !child.is_a?(CommentNode)
if !child.is_a?(PropNode) && !child.is_a?(CommentNode)
"Illegal nesting: Only properties may be nested beneath properties."
end
end