Last February, wereleased the first beta of jQuery 4.0.0. We’re now ready to release a second, and we expect a release candidate to come soon™. This release comes with amajor rewrite to jQuery’s testing infrastructure, which removed all deprecated or under-supported dependencies. But the main change that warranted a second beta was a fix to theexports field for bundlers. More on that and other changes below.
Many of the breaking changes in jQuery 4.0.0 are ones the team has wanted to make for years, but couldn’t in a patch or minor release. We’ve trimmed legacy code (including removing support for IE before version 11), removed some previously-deprecated APIs, removed some internal-only parameters to public functions that were never documented, and dropped support for some “magic” behaviors that were overly complicated.
We will publish a comprehensive upgrade guide before final release, to outline the removed code and how to migrate. ThejQuery Migrate plugin will also be ready to assist. For now, please try out this release andlet us know if you encounter any issues.
As usual, the release is available onour CDN and the npm package manager. Third party CDNs will not be hosting this beta release, but will host the 4.0.0 final release later. Here are some highlights for jQuery 4.0.0 beta.2.
There are many different ways to include jQuery in a project. Supporting all of them can be difficult, especially when the environment supports both CommonJS and ESM modules. We wanted to support all of the ways jQuery might be included, whether using a named export or the default export. Also, we wanted to ensure jQuery was only ever included once, even when jQuery was bothimport
ed using ESM andrequire
d using CommonJS in the same environment or bundle. We think we’ve worked out a solution that supports Node.js and bundlers like rollup, webpack, and parcel. More details can be found in thePR. Also, we created awiki page to explain how theexports
property in jQuery’spackage.json
will work in 4.0.
The HTML spec defines boolean attributes that often correlate with boolean properties. If the attribute is missing, it correlates with thefalse
property value, if it’s present – the true property value. The only valid values for boolean content attributes are empty string or the full attribute name (e.g.checked="checked"
).
jQuery has historically tried to be helpful here and treated boolean attributes in a special way in the.attr()
API:
false
was passed;The problem is the spec occasionally converts boolean attributes into ones with additional attribute values with special behavior – one such example is the new"until-found"
value for thehidden
attribute. Our setter normalization meant passing those values was impossible with.attr()
(.prop()
was unaffected). Also, new boolean attributes were introduced occasionally and jQuery could not easily add them to the list without incurring breaking changes.
This patch removes any special handling of boolean attributes – the getter returns the value as-is and the setter sets the provided value, with one exception. To maintain backwards compatibility, this patch makes thefalse
boolean value trigger attribute removal for ALL non-ARIA attributes. For example,.attr( "checked", false )
will continue to remove thechecked
attribute, which is the only way the corresponding property will be set tofalse
. ARIA attributes are exempt from the rule since many of them recognize the string"false"
as a valid value with semantics different than the attribute missing. To remove an ARIA attribute, use.removeAttr()
or passnull
as the value to.attr()
.
jQuery 4.0.0-beta.2 also fixes some inconsistent behavior when finding the position of elements within tables. The offset parent on which the position was based could change depending on whether the element’sposition
style wasstatic
orrelative
.
<div> <table> <tr> <td> <span></span> <span></span> </td> </tr> </table></div>
Previously, $('#static').position()
was returning the position relative to the containing <td>
element, while $('#relative').position()
was returning the position relative to #container
.
Now, both elements return their position relative to#container
.
You can get the files from the jQuery CDN, or link to them directly:
https://code.jquery.com/jquery-4.0.0-beta.2.js
https://code.jquery.com/jquery-4.0.0-beta.2.min.js
You can also get this release from npm:
npm install jquery@4.0.0-beta.2
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. Finally, all of jQuery’s supported browsers (except for IE11) now have support for native Promises across the board, so Deferreds and Callbacks are no longer needed in most cases. Along with the regular version of jQuery that includes everything, 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 8k gzipped bytes smaller than the regular version. These files are also available in the npm package and on the CDN:
https://code.jquery.com/jquery-4.0.0-beta.2.slim.js
https://code.jquery.com/jquery-4.0.0-beta.2.slim.min.js
These updates are already available as the current versions on npm. Information on all the ways to get jQuery is available athttps://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, includingMichał Gołębiowski-Owczarek,J.Son,Liam James and the whole jQuery team.
jQuery has a Mastodon account! We now post releases and other updates to both X and Mastodon. Also, you may be interested in following some of our team members that have Mastodon accounts.
jQuery:https://social.lfx.dev/@jquery
mgol:https://hachyderm.io/@mgol
timmywil:https://hachyderm.io/@timmywil
Full changelog:4.0.0-beta.2
:has
selector tests with3.x-stable
(f2d9fde5)Comments are closed.