bgrins / spectrum

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

change event is fired when empty color is not changed #300

Open l0g0sys opened 9 years ago

l0g0sys commented 9 years ago

Spectrum with option allowEmpty set to true fires change event on input element when empty color isn't changed.

Simple fix:

    // `equals`
    // Can be called with any tinycolor input
    tinycolor.equals = function (color1, color2) {
+       if (!color1 && !color2) { return true; }
        if (!color1 || !color2) { return false; }
        return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
    };
ninio commented 8 years ago

+1