jQuery 3.6.2 Released!
You probably weren’t expecting another release so soon, but jQuery 3.6.2 has arrived! The main impetus for this release was the introduction of some new selectors in Chrome. More on that below.
As usual, the release is available on our cdn and the npm package manager. Other third party CDNs will probably have it soon as well, but remember that we don’t control their release schedules and they will need some time. Here are the highlights for jQuery 3.6.2.
undefined and whitespace-only CSS variables
jQuery 3.6.1 introduced a minor regression where attempting to retrieve a value for a custom CSS property that didn’t exist (i.e.
$elem.css("--custom")) threw an error instead of returning undefined. This has been fixed in 3.6.2. Related to that, we also made sure that whitespace-only values return the same thing across all browsers. The spec requires that CSS variable values be trimmed, but browsers are inconsistent in their trimming. We now return undefined for whitespace-only values to make it consistent with older jQuery and across the different browsers.
.contains() with <template>
An issue was recently reported that showed that a
<template>‘s document had its
documentElement property set to
null, in compliance with the spec. While it made sense semantically for a template to not yet be tied to a document, it made for an unusual case, specifically in
jQuery.contains() and any methods relying on it. That included manipulation and selector methods. Fortunately, the fix was simple.
It wasn’t Ralph that broke the internet
The internet experienced a bit of a rumble when Chrome recently introduced some new selectors, the most pertinent of which being
:has(). It was a welcome addition, and one celebrated by the jQuery team, but a change to the spec meant that
:has() used what’s called “forgiving parsing”. Essentially, even if the arguments for
:has() were invalid, the browser returned no results instead of throwing an error. That was problematic in cases where
:has() contained another jQuery selector extension (e.g.
:has(:contains("Item"))) or contained itself (
:has(div:has(a))). Sizzle relied on errors like that to know when to trust native
querySelectorAll and when to run the selector through Sizzle. Selectors that used to work were broken in all jQuery versions dating back to the earliest jQuery versions.
And yet, this little drama didn’t last long. The Chrome team quickly implemented a workaround to fix previous jQuery versions in the vast majority of cases. Safari handled their implementation of
:has() a little differently and didn’t have the same problem.
But, there’s still an important issue open to determine how to address this in the CSS spec itself. The CSSWG has since resolved the issue.
jQuery has taken steps to ensure that any forgiving parsing doesn’t break future jQuery versions, even if previous jQuery versions would still be affected.
We do not expect compatibility issues when upgrading from a jQuery 3.0+ version. To upgrade, have a look at the new 3.5 Upgrade Guide. If you haven’t yet upgraded to jQuery 3+, first have a look at the 3.0 Upgrade Guide.
If you can’t yet upgrade to 3.5+, Daniel Ruf has kindly provided patches for previous jQuery versions.
You can get the files from the jQuery CDN, or link to them directly:
You can also get this release from npm:
npm install email@example.com
Sometimes you don’t need ajax, or you prefer to use one of the many standalone libraries that focus on ajax requests. And often it is simpler to use a combination of CSS and class manipulation for web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’ve released a “slim” version that excludes these modules. The size of jQuery is very rarely a load performance concern these days, but the slim build is about 6k gzipped bytes smaller than the regular version. These files are also available in the npm package and on the CDN:
These updates are already available as the current versions on npm and Bower. Information on all the ways to get jQuery is available at https://jquery.com/download/. Public CDNs receive their copies today, please give them a few days to post the files. If you’re anxious to get a quick start, use the files on our CDN until they have a chance to update.
Thank you to all of you who participated in this release by submitting patches, reporting bugs, or testing, including sashashura, Anders Kaseorg, Michal Golebiowski-Owczarek, and the whole jQuery team.
Full changelog: 3.6.2
undefinedfor whitespace-only CSS variable values (#5120) (8bea1dec)
- Don’t trim whitespace of undefined custom property (#5105, c0db6d70)
- Manipulation: Fix DOM manip within template contents (#5147, 5318e311)
- Update Sizzle from 2.3.7 to 2.3.8 (#5147, a1b7ae3b)
- Update Sizzle from 2.3.6 to 2.3.7 (#5098, ee0fec05)