File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -2000,6 +2000,21 @@ namespace Sass {
2000
2000
return false ;
2001
2001
}
2002
2002
2003
+ bool Number::eq (const Expression& rhs) const
2004
+ {
2005
+ if (const Number* r = dynamic_cast <const Number*>(&rhs)) {
2006
+ size_t lhs_units = numerator_units_.size () + denominator_units_.size ();
2007
+ size_t rhs_units = r->numerator_units_ .size () + r->denominator_units_ .size ();
2008
+ if (!lhs_units && !rhs_units) {
2009
+ return std::fabs (value () - r->value ()) < NUMBER_EPSILON;
2010
+ }
2011
+ return (numerator_units_ == r->numerator_units_ ) &&
2012
+ (denominator_units_ == r->denominator_units_ ) &&
2013
+ std::fabs (value () - r->value ()) < NUMBER_EPSILON;
2014
+ }
2015
+ return false ;
2016
+ }
2017
+
2003
2018
bool Number::operator == (const Expression& rhs) const
2004
2019
{
2005
2020
if (const Number* r = dynamic_cast <const Number*>(&rhs)) {
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ namespace Sass {
152
152
static std::string type_name () { return " " ; }
153
153
virtual bool is_false () { return false ; }
154
154
virtual bool operator == (const Expression& rhs) const { return false ; }
155
+ virtual bool eq (const Expression& rhs) const { return *this == rhs; };
155
156
virtual void set_delayed (bool delayed) { is_delayed (delayed); }
156
157
virtual bool has_interpolant () const { return is_interpolant (); }
157
158
virtual bool is_left_interpolant () const { return is_interpolant (); }
@@ -289,7 +290,7 @@ namespace Sass {
289
290
};
290
291
struct CompareExpression {
291
292
bool operator ()(const Expression* lhs, const Expression* rhs) const {
292
- return lhs && rhs && * lhs == *rhs;
293
+ return lhs && rhs && lhs-> eq ( *rhs) ;
293
294
}
294
295
};
295
296
typedef std::unordered_map<
@@ -1371,6 +1372,7 @@ namespace Sass {
1371
1372
1372
1373
virtual bool operator < (const Number& rhs) const ;
1373
1374
virtual bool operator == (const Expression& rhs) const ;
1375
+ virtual bool eq (const Expression& rhs) const ;
1374
1376
1375
1377
ATTACH_OPERATIONS ()
1376
1378
};
You can’t perform that action at this time.
0 commit comments