You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CSS variable stripped from calls to jQuery .css() #2411
I found an odd behavior in the jQuery Core .css() function when passing values that contain CSS variables, with a color value as fallback. This bug only happens when jQuery UI is also loaded on the page, and seems to be caused by the jQuery Color plugin (as vendored by jQuery UI) and its cssHooks for converting colors to rgb() notation.
This is not limited to the return value, the style attribute itself is altered so this happens during the setting, not the getting.
The impact is that when you later attach the element to the document, where the CSS variable exists in a stylesheet, its value will not be used, and instead the fallback is always used.
This was found downstream at Wikipedia (https://phabricator.wikimedia.org/T391461), where we found theme variables (especially dark mode) causing some challenging color combinations. The issue only happened on the subset of forms where jQuery UI is loaded by something elsewhere on the page.
I'm looking at patching https://github.com/jquery/jquery-color to add a regex anchor but wondering about back-compat with regards to whitespace. Today, the hook technically matches inputs like #202FF2 , but it may or may not have to.
Firefox, Safari, and Chrome agree in how they accept it as input:
Activity
Krinkle commentedon Jul 22, 2026
I'm looking at patching https://github.com/jquery/jquery-color to add a regex anchor but wondering about back-compat with regards to whitespace. Today, the hook technically matches inputs like
#202FF2, but it may or may not have to.Firefox, Safari, and Chrome agree in how they accept it as input:
Idem when using
.css()without jQuery Color (or jQuery UI) loaded:But... while it may get trimmed eventually, it is not trimmed before making it into cssHooks:
So to make the smallest possible change, I'll keep tolerance for leading whitespace, and leave off any end anchor.
Krinkle commentedon Jul 22, 2026
Looking at the
stringParse()implementation I note that the above does not hold for color keywords.At https://jqueryui.com/resources/demos/draggable/default.html with jQuery UI/jQuery color loaded:
Core: Fix parsing to preserve CSS variables with fallback colors
Core: Fix parsing to preserve CSS variables with fallback colors
Core: Fix parsing to preserve CSS variables with fallback colors
Core: Fix parsing to preserve CSS variables with fallback colors
Core: Fix parsing to preserve CSS variables with fallback colors
mgol commentedon Sep 25, 2026
Reopening as we still need to pull in that jQuery Color release.