bgrins/spectrum

Problem after upgrading to JQuery 3.5.1

DumboJet opened this issue · 2 comments

I am not sure how and why this happens, but after upgrading to JQuery 3.51 (from 3.4.1), a lot of my libraries broke, including spectrum.
Every instance of <i /> or <span /> had to be replaced by the corresponding non-self-closing tag, like <i></i>.
Silly HTML language...

I had to fix your library by changing this self-closing tag:
image
Otherwise, the palette was broken.

I noticed that reverting JQuery back to the old version fixed the problem, but I might be wrong, so maybe try to verify this on your end too. It might have been a different library that caused this, because it was a whole "library-upgrade day" for me when it happened...

Update:
Ohh!!!
Actually, the 1.8.1 version published here has this fix, but if you download the 1.8.0 release ZIP, it doesn't!

I can confirm that v1.8.0 breaks with the new jQuery due to the self-closing tag issue, and that the issue is fixed in v1.8.1

It seems that there is bug in version 1.8.1 the problem is this code:

            function paletteElementClick(e) {
                if (e.data && e.data.ignore) {
                    set($(e.target).closest(".sp-thumb-el").data("color"));
                    move();
                }
                else {
                    set($(e.target).closest(".sp-thumb-el").data("color"));
                    move();

                    // If the picker is going to close immediately, a palette selection
                    // is a change.  Otherwise, it's a move only.
                    if (opts.hideAfterPaletteSelect) {
                        updateOriginalInput(true);
                        hide();
                    } else {
                        updateOriginalInput(); // here there should be true passed as argument
                    }
                }

                return false;
            }

When hideAfterPaletteSelect is not set it don't trigger the callback events. Which make ignore the pick of the palette.

The code should look like this:

                    updateOriginalInput(true);
                    if (opts.hideAfterPaletteSelect) {
                        hide();
                    }

If you want this to work like input, then this is breaking change.