bgrins / spectrum

The No Hassle JavaScript Colorpicker
https://bgrins.github.io/spectrum/
MIT License
2.32k stars 588 forks source link

Fixed Issue #300 #388

Open ninio opened 8 years ago

ninio commented 8 years ago

If both the color1 and color2 are null the equals used to return false. Now it returns true

bgrins commented 8 years ago

Hi, thanks for the PR. Can you please open it on https://github.com/bgrins/TinyColor/?

bgrins commented 8 years ago

Actually the more I think about it I wonder if this should be done outside of tinycolor.equals. I don't think tinycolor.equals(false, null) should really be true, for instance. So maybe we should be handling this with a separate helper function in spectrum called colorsEqual or something that does the additional check before calling into tinycolor.equals

ninio commented 8 years ago

You have a point that false and null shouldn't be equal colors. Although it is a matter of perspective.. We can think that everything that's not a color is actually the same thing.

It might make sense to use a strict equality in case of !color1 && !color2

The real problem related to spectrum is that an onchange event is triggered when there is no change (the old and the new values are null)

I've opened this issue in the TinyColor - https://github.com/bgrins/TinyColor/issues/121