@@ -61,6 +61,19 @@ namespace Sass {
6161
6262 string Node::unquote () const
6363 {
64+ Type t = type ();
65+ switch (type ())
66+ {
67+ case string_constant:
68+ case identifier: {
69+ return token ().unquote ();
70+ } break ;
71+
72+ default : {
73+ // do nothing; fall though to the rest
74+ } break ;
75+ }
76+
6477 string intermediate (to_string ());
6578 if (!intermediate.empty () && (intermediate[0 ] == ' "' || intermediate[0 ] == ' \' ' )) {
6679 return intermediate.substr (1 , intermediate.length () - 2 );
@@ -74,8 +87,11 @@ namespace Sass {
7487 {
7588 Type t = type (), u = rhs.type ();
7689
77- if ((t == identifier || t == string_constant || t == string_schema || t == concatenation) &&
78- (u == identifier || u == string_constant || u == string_schema || u == concatenation)) {
90+ // if ((t == identifier || t == string_constant || t == string_schema || t == concatenation) &&
91+ // (u == identifier || u == string_constant || u == string_schema || u == concatenation)) {
92+ // return unquote() == rhs.unquote();
93+ // }
94+ if (is_string () && rhs.is_string ()) {
7995 return unquote () == rhs.unquote ();
8096 }
8197 else if (t != u) {
@@ -126,8 +142,25 @@ namespace Sass {
126142 return boolean_value () == rhs.boolean_value ();
127143 } break ;
128144
145+ case selector: {
146+ if (has_children () && rhs.has_children () && (size () == rhs.size ())) {
147+ for (size_t i = 0 , S = size (); i < S; ++i) {
148+ if (at (i) == rhs[i]) continue ;
149+ else return false ;
150+ }
151+ return true ;
152+ }
153+ else {
154+ return false ;
155+ }
156+ } break ;
157+
158+ case simple_selector: {
159+ if (token () == rhs.token ()) return true ;
160+ } break ;
161+
129162 default : {
130- return true ;
163+ return false ;
131164 } break ;
132165 }
133166 return false ;
@@ -163,12 +196,16 @@ namespace Sass {
163196 }
164197
165198 // comparing identifiers and strings (treat them as comparable)
166- else if ((lhs_type == identifier || lhs_type == string_constant || lhs_type == value) &&
167- (rhs_type == identifier || lhs_type == string_constant || rhs_type == value)) {
168- return token ().unquote () < rhs.token ().unquote ();
199+ else if (is_string () && rhs.is_string ()) {
200+ return unquote () < rhs.unquote ();
169201 }
170202
171- // COMPARING SELECTORS -- IMPORTANT FOR INHERITANCE
203+ // else if ((lhs_type == identifier || lhs_type == string_constant || lhs_type == value) &&
204+ // (rhs_type == identifier || lhs_type == string_constant || rhs_type == value)) {
205+ // return token().unquote() < rhs.token().unquote();
206+ // }
207+
208+ // COMPARING SELECTORS -- IMPORTANT FOR ORDERING AND NORMALIZING
172209 else if ((type () >= selector_group && type () <=selector_schema) &&
173210 (rhs.type () >= selector_group && rhs.type () <=selector_schema)) {
174211
@@ -183,13 +220,15 @@ namespace Sass {
183220 return token () < rhs.token ();
184221 } break ;
185222
223+ // assumes selectors are normalized by the time they're compared
186224 case selector:
187- case attribute_selector: {
225+ case simple_selector_sequence:
226+ case attribute_selector:
227+ case functional_pseudo:
228+ case pseudo_not: {
188229 return lexicographical_compare (begin (), end (), rhs.begin (), rhs.end ());
189230 } break ;
190231
191-
192-
193232 default : {
194233 return false ;
195234 } break ;
0 commit comments