@@ -1256,8 +1256,10 @@ namespace Sass {
12561256 while (true ) {
12571257 r = u.find_first_of (" */" , l);
12581258 string unit (u.substr (l, r == string::npos ? r : r - l));
1259- if (nominator) numerator_units_.push_back (unit);
1260- else denominator_units_.push_back (unit);
1259+ if (!unit.empty ()) {
1260+ if (nominator) numerator_units_.push_back (unit);
1261+ else denominator_units_.push_back (unit);
1262+ }
12611263 if (r == string::npos) break ;
12621264 // ToDo: should error for multiple slashes
12631265 // if (!nominator && u[r] == '/') error(...)
@@ -1287,7 +1289,7 @@ namespace Sass {
12871289 bool Number::is_unitless ()
12881290 { return numerator_units_.empty () && denominator_units_.empty (); }
12891291
1290- void Number::normalize (const string& prefered)
1292+ void Number::normalize (const string& prefered, bool strict )
12911293 {
12921294
12931295 // first make sure same units cancel each other out
@@ -1331,7 +1333,7 @@ namespace Sass {
13311333 if (string_to_unit (nom) == UNKNOWN) continue ;
13321334 // we now have two convertable units
13331335 // add factor for current conversion
1334- factor *= conversion_factor (nom, denom);
1336+ factor *= conversion_factor (nom, denom, strict );
13351337 // update nominator/denominator exponent
13361338 -- exponents[nom]; ++ exponents[denom];
13371339 // inner loop done
@@ -1352,8 +1354,10 @@ namespace Sass {
13521354 {
13531355 // opted to have these switches in the inner loop
13541356 // makes it more readable and should not cost much
1355- if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1356- else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1357+ if (!exp.first .empty ()) {
1358+ if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1359+ else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1360+ }
13571361 }
13581362 }
13591363
@@ -1363,14 +1367,14 @@ namespace Sass {
13631367
13641368 // maybe convert to other unit
13651369 // easier implemented on its own
1366- try { convert (prefered); }
1370+ try { convert (prefered, strict ); }
13671371 catch (incompatibleUnits& err)
13681372 { error (err.what (), pstate ()); }
13691373 catch (...) { throw ; }
13701374
13711375 }
13721376
1373- void Number::convert (const string& prefered)
1377+ void Number::convert (const string& prefered, bool strict )
13741378 {
13751379 // abort if unit is empty
13761380 if (prefered.empty ()) return ;
@@ -1405,7 +1409,7 @@ namespace Sass {
14051409 if (string_to_unit (denom) == UNKNOWN) continue ;
14061410 // we now have two convertable units
14071411 // add factor for current conversion
1408- factor *= conversion_factor (denom, prefered);
1412+ factor *= conversion_factor (denom, prefered, strict );
14091413 // update nominator/denominator exponent
14101414 ++ exponents[denom]; -- exponents[prefered];
14111415 }
@@ -1426,7 +1430,7 @@ namespace Sass {
14261430 if (string_to_unit (nom) == UNKNOWN) continue ;
14271431 // we now have two convertable units
14281432 // add factor for current conversion
1429- factor *= conversion_factor (nom, prefered);
1433+ factor *= conversion_factor (nom, prefered, strict );
14301434 // update nominator/denominator exponent
14311435 -- exponents[nom]; ++ exponents[prefered];
14321436 }
@@ -1444,8 +1448,10 @@ namespace Sass {
14441448 {
14451449 // opted to have these switches in the inner loop
14461450 // makes it more readable and should not cost much
1447- if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1448- else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1451+ if (!exp.first .empty ()) {
1452+ if (exp.second < 0 ) denominator_units_.push_back (exp.first );
1453+ else if (exp.second > 0 ) numerator_units_.push_back (exp.first );
1454+ }
14491455 }
14501456 }
14511457
0 commit comments