Closed DEfusion closed 4 years ago
Thanks for the fix! Theoretically it could by done even simpler as NaN
is falsy a val || 0
would've been sufficient :D
Note that normally you'd use
Number.isNaN
becausewindow.IsNaN
only checks whether the value is not a number andNumber.isNaN
actually checks forNaN
, see this SO Answer.
When given a hsl value with both 0 for the saturation and lightness (i.e. black;
hsl(0, 0%, 0%)
) that would result in a division by 0 in the conversion resulting inNaN
for the saturation for the hsv result.This would most easily manifest itself if a swatch were set with the
hsl
value for black, which would generate an invalid color e.g.#00NANNAN
for the hex representation:This change fixes that by setting it to 0 when the new saturation results in
NaN
.