From 9571d9af297de53c5939ca1af6ed83b5a4544868 Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Thu, 19 Feb 2009 20:05:11 -0800 Subject: [PATCH] [Sass] Fix a bug in css2sass exposed by css2sass_test. --- lib/sass/css.rb | 2 +- lib/sass/tree/attr_node.rb | 4 ++++ lib/sass/tree/node.rb | 4 ++++ lib/sass/tree/rule_node.rb | 4 ++++ lib/sass/tree/value_node.rb | 4 ++++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/sass/css.rb b/lib/sass/css.rb index b98b117d..3eae4338 100644 --- a/lib/sass/css.rb +++ b/lib/sass/css.rb @@ -377,7 +377,7 @@ module Sass def fold_commas(root) prev_rule = nil root.children.map! do |child| - next child unless Tree::RuleNode === child + next child unless child.is_a?(Tree::RuleNode) if prev_rule && prev_rule.children == child.children prev_rule.rule << ", #{child.rule}" diff --git a/lib/sass/tree/attr_node.rb b/lib/sass/tree/attr_node.rb index c4054604..3f3ed4b5 100644 --- a/lib/sass/tree/attr_node.rb +++ b/lib/sass/tree/attr_node.rb @@ -9,6 +9,10 @@ module Sass::Tree super(value, style) end + def ==(other) + self.class == other.class && name == other.name && super + end + def to_s(tabs, parent_name = nil) if value[-1] == ?; raise Sass::SyntaxError.new("Invalid attribute: #{declaration.dump} (This isn't CSS!).", @line) diff --git a/lib/sass/tree/node.rb b/lib/sass/tree/node.rb index cf536d3c..a9c7518f 100644 --- a/lib/sass/tree/node.rb +++ b/lib/sass/tree/node.rb @@ -17,6 +17,10 @@ module Sass @children << child end + def ==(other) + self.class == other.class && other.children == children + end + def to_s result = String.new children.each do |child| diff --git a/lib/sass/tree/rule_node.rb b/lib/sass/tree/rule_node.rb index 1292ae57..62ad4594 100644 --- a/lib/sass/tree/rule_node.rb +++ b/lib/sass/tree/rule_node.rb @@ -9,6 +9,10 @@ module Sass::Tree alias_method :rule, :value alias_method :rule=, :value= + def ==(other) + self.class == other.class && rules == other.rules && super + end + def rules Array(rule) end diff --git a/lib/sass/tree/value_node.rb b/lib/sass/tree/value_node.rb index b6a30051..9ce97416 100644 --- a/lib/sass/tree/value_node.rb +++ b/lib/sass/tree/value_node.rb @@ -9,6 +9,10 @@ module Sass::Tree super(style) end + def ==(other) + self.class == other.class && value == other.value && super + end + def to_s(tabs = 0) value end