jQuery 3.0 Alpha now available
The alpha version for jQuery 3.0 has landed and with it a focus on updates to closer match the HTML5 dataset specification. Build, core and CSS changes take up the majority of the release, while jQuery Promises also receives some attention.
jQuery is embarking on another major release as jQuery 3.0 Alpha arrives with a fresh version bump. Joining the release party is jQuery Compat 3.0, which includes support for Internet Explorer 8.
Some breaking changes are definitely on the cards in jQuery 3.0 and punters can expect more features in general to be added to the beta and final versions of the release. Simplified
.hide() methods top the features list, ending the “many complex special cases” vortex the jQuery team often found themselves in.
You can see that jQuery was already about halfway down the path to total madness, and it didn’t make sense to complete the journey. The special cases and checks were not only complex and incomplete, but they caused significant performance issues on large pages.
Timmy Willison from the team describes the evolution of these methods culminating in a simple, primordial model. However, this also means some code is going be broken. “If you have elements in a stylesheet that are set to
display: none, the
.show() method will no longer override that”.
For the jQuery 3.0 move, it’s recommended that developers not use a stylesheet to set the default of
display: none and then try to use
.show() – or any method that shows elements to make it visible. The team has recognised that the change could be quite contentious and hard to adjust to, so they’re happy to receive feedback as to how it affects your code.
.data() implementation has been updates to play nice with the HTML5 dataset specification, meaning keys have been converted from kebab-case to camelCase, regardless of access method. Users should also be aware that digits no longer have a part in the conversion.
The major change that a lot of developers are excited about however is the fact that jQuery.Deferred is now Promises/A+ compatible. The introduction of a
.catch() method has been made necessary, on top of some major changes listed by Willison to the
- Callbacks are always invoked asynchronously
- Progress callbacks can no longer resolve Deferred objects to which they are bound
- An exception thrown in a
.then()callback now becomes a rejection value
- The resolution state of a Deferred created by
.then()is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfilment values
All Promises changes have been verified against the Promises/A+ Compliance Test Suite.
Further major changes in the alpha include the removal of special-case Deferred methods in jQuery.ajax, removal of deprecated event aliases and the use of Animations. More detailed information about each change, plus the whole change list, can be found at Willison’s original blog post here.