[Sass] Don't violate #children's typing in Tree::CommentNode.

This commit is contained in:
Nathan Weizenbaum 2009-04-25 00:09:44 -07:00
parent d39d2eba13
commit ebd8872b8e
2 changed files with 7 additions and 11 deletions

View File

@ -186,10 +186,10 @@ END
node.line = line.index node.line = line.index
node.filename = line.filename node.filename = line.filename
unless node.is_a?(Tree::CommentNode) if node.is_a?(Tree::CommentNode)
append_children(node, line.children, false) node.lines = line.children
else else
node.children = line.children append_children(node, line.children, false)
end end
return node return node
end end

View File

@ -2,15 +2,17 @@ require 'sass/tree/node'
module Sass::Tree module Sass::Tree
class CommentNode < Node class CommentNode < Node
attr_accessor :lines
attr_accessor :value attr_accessor :value
def initialize(value, options) def initialize(value, options)
@lines = []
@value = value[2..-1].strip @value = value[2..-1].strip
super(options) super(options)
end end
def ==(other) def ==(other)
self.value == other.value && super self.class == other.class && value == other.value && lines == other.lines
end end
def silent? def silent?
@ -21,14 +23,8 @@ module Sass::Tree
return if (@style == :compressed || silent?) return if (@style == :compressed || silent?)
spaces = ' ' * (tabs - 1) spaces = ' ' * (tabs - 1)
spaces + "/* " + ([value] + children.map {|c| c.text}). spaces + "/* " + ([value] + lines.map {|l| l.text}).
map{|l| l.sub(%r{ ?\*/ *$},'')}.join(@style == :compact ? ' ' : "\n#{spaces} * ") + " */" map{|l| l.sub(%r{ ?\*/ *$},'')}.join(@style == :compact ? ' ' : "\n#{spaces} * ") + " */"
end end
protected
def _perform(environment)
self
end
end end
end end