@@ -960,8 +960,10 @@ namespace Sass {
960960 while (true ) {
961961 r = u.find_first_of (" */" , l);
962962 string unit (u.substr (l, r == string::npos ? r : r - l));
963- if (nominator) numerator_units_.push_back (unit);
964- else denominator_units_.push_back (unit);
963+ if (!unit.empty ()) {
964+ if (nominator) numerator_units_.push_back (unit);
965+ else denominator_units_.push_back (unit);
966+ }
965967 if (r == string::npos) break ;
966968 // ToDo: should error for multiple slashes
967969 // if (!nominator && u[r] == '/') error(...)
@@ -991,7 +993,7 @@ namespace Sass {
991993 bool Number::is_unitless ()
992994 { return numerator_units_.empty () && denominator_units_.empty (); }
993995
994- void Number::normalize (const string& prefered)
996+ void Number::normalize (const string& prefered, bool strict )
995997 {
996998
997999 // first make sure same units cancel each other out
@@ -1035,7 +1037,7 @@ namespace Sass {
10351037 if (string_to_unit (nom) == UNKNOWN) continue ;
10361038 // we now have two convertable units
10371039 // add factor for current conversion
1038- factor *= conversion_factor (nom, denom);
1040+ factor *= conversion_factor (nom, denom, strict );
10391041 // update nominator/denominator exponent
10401042 -- exponents[nom]; ++ exponents[denom];
10411043 // inner loop done
@@ -1056,8 +1058,10 @@ namespace Sass {
10561058 {
10571059 // opted to have these switches in the inner loop
10581060 // makes it more readable and should not cost much
1059- if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1060- else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1061+ if (!exp.first .empty ()) {
1062+ if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1063+ else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1064+ }
10611065 }
10621066 }
10631067
@@ -1067,14 +1071,14 @@ namespace Sass {
10671071
10681072 // maybe convert to other unit
10691073 // easier implemented on its own
1070- try { convert (prefered); }
1074+ try { convert (prefered, strict ); }
10711075 catch (incompatibleUnits& err)
10721076 { error (err.what (), pstate ()); }
10731077 catch (...) { throw ; }
10741078
10751079 }
10761080
1077- void Number::convert (const string& prefered)
1081+ void Number::convert (const string& prefered, bool strict )
10781082 {
10791083 // abort if unit is empty
10801084 if (prefered.empty ()) return ;
@@ -1109,7 +1113,7 @@ namespace Sass {
11091113 if (string_to_unit (denom) == UNKNOWN) continue ;
11101114 // we now have two convertable units
11111115 // add factor for current conversion
1112- factor *= conversion_factor (denom, prefered);
1116+ factor *= conversion_factor (denom, prefered, strict );
11131117 // update nominator/denominator exponent
11141118 ++ exponents[denom]; -- exponents[prefered];
11151119 }
@@ -1130,7 +1134,7 @@ namespace Sass {
11301134 if (string_to_unit (nom) == UNKNOWN) continue ;
11311135 // we now have two convertable units
11321136 // add factor for current conversion
1133- factor *= conversion_factor (nom, prefered);
1137+ factor *= conversion_factor (nom, prefered, strict );
11341138 // update nominator/denominator exponent
11351139 -- exponents[nom]; ++ exponents[prefered];
11361140 }
@@ -1148,8 +1152,10 @@ namespace Sass {
11481152 {
11491153 // opted to have these switches in the inner loop
11501154 // makes it more readable and should not cost much
1151- if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1152- else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1155+ if (!exp.first .empty ()) {
1156+ if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1157+ else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1158+ }
11531159 }
11541160 }
11551161
0 commit comments