Search code examples
cssrubysasscompass

Sass color mix function produce different results for different ruby versions


Color output after compiling sass files differed between ruby 2.1.6 and 2.2.2. Is this a freak occurrence, or can we expect the mix function do produce different values if we upgrade Ruby in the future?

// test.scss
$white: white;
$black: black;
$dark-text: #2e3135;
$offwhite: #f7f8f8;
$error: #e32908;

.mixed {
  color: mix($white, $black);
  color: mix($black, $error);
  color: mix($dark-text, $offwhite);
}

Compiled with 2.1.6

//ruby 2.1.6p336 (2015-04-13 revision 50298) [x64-mingw32]
//Compass 1.0.3 (Polaris)
//Sass 3.4.13 (Selective Steve)

.mixed {
  color: #7f7f7f;
  color: #711404;
  color: #929496;
}

Compiled with 2.2.2

//ruby 2.2.2p95 (2015-04-13 revision 50295) [x64-mingw32]
//Compass 1.0.3 (Polaris)
//Sass 3.4.15 (Selective Steve):

.mixed {
  color: gray;
  color: #721504;
  color: #939597;
}

The color differences are pretty minor, so it doesn't matter, but it would be interesting to know what happened.


Solution

  • Found this in the Sass changelog after the comment from @cimmanon

    3.4.15 (22 June 2015)

    • Further improve rounding for various numeric operations.
    • Imp rounding in operator-based color operations.