siege-media / contrast-ratio

A tool to calculate the contrast ratio between any two valid CSS colors.
https://www.siegemedia.com/contrast-ratio
MIT License
2.45k stars 221 forks source link

fix: farthest compare logic #45

Open caijf opened 2 years ago

LeaVerou commented 2 years ago

Hey, thanks! Which bug does this fix?

caijf commented 2 years ago
var max = Math.max(contrastOnBlack, contrastOnWhite);
// ...

return {
  // ...
  farthest: onWhite == max? _.WHITE : _.BLACK
}

onWhite == max The conditional judgment here is always no. I think it should be contrastOnWhite == max .