jQuery 3.4.1: triggering focus events in IE and finding root elements in iOS 10

Posted on by

Hello again! jQuery 3.4.0 was released just three weeks ago, but we’ve had a few issues reported that warranted a patch release. Thank you to everyone that reported issues and helped us get these fixed quickly. Here are the changes:

Triggering focus or blur more than once in IE

jQuery 3.4.0 came with some changes to the way the event handler triggered native events such focus and blur. These changes caused a regression that sometimes resulted in an enigmatic error being thrown in the form of "saved.shift is not a function". This is now fixed.

Example

// Error thrown in IE10-11
// after clicking #test-element twice
jQuery("#test-element").click(function() {
  jQuery(this).trigger("blur");
});

Checking element attachment in iOS 10.0-10.2

When releasing 3.4.0, we ran our tests in several versions of iOS, including iOS 10.3 but not 10.0-10.2. Those versions do not support a native function we use to determine whether an element is attached to the DOM. Other versions of iOS were not affected. We added a guard to ensure that this method exists and fall back to other options if necessary.

Loading jQuery with AMD

A small module was added in jQuery 3.4.0 that used the global jQuery rather than the local jQuery loaded with AMD. This resulted in "jQuery is undefined" errors when loading with AMD, but this should now be fixed.

 


Upgrading

There should be no compatibility issues if upgrading from jQuery 3.0+. If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.4.1.js

https://code.jquery.com/jquery-3.4.1.min.js

You can also get this release from npm:

npm install jquery@3.4.1

Slim build

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:

https://code.jquery.com/jquery-3.4.1.slim.js

https://code.jquery.com/jquery-3.4.1.slim.min.js

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.

Thanks

Thank you to all of you who participated in this release by submitting patches, reporting bugs, or testing, including Richard Gibson, Michal Golebiowski-Owczarek, and the whole jQuery team.

Changelog

GitHub changelog: Issues fixed in 3.4.1 | All changes

Build

  • Fix unresolved jQuery reference in finalPropName (#4358, 0d4af529)

Core

Event

  • Prevent leverageNative from registering duplicate dummy handlers (6c1e7dbf)
  • Fix handling of multiple async focus events (#4350, 24d71ac7)

jQuery 3.4.0 Released

Posted on by

jQuery has a new release! It’s been a while since our last release, but we expect this to be the last minor release in the 3.x branch, and then we will move on to the overhaul that will be jQuery 4.0. But before we get to 4.0, we’re excited to share the bug fixes and improvements included in jQuery 3.4.0. Here are some of the highlights:

Performance improvement in .width and .height

When getting and setting dimensions, there were certain cases where this could cause layout thrashing, which basically means that the browser calculated layout more times than necessary. We fixed this in all browsers except IE, where it can’t be avoided.

nonce and nomodule support

To support adding script elements through methods like .html and .append, jQuery separates them and appends new script tags to load and execute the remote content. During this process, attributes such as nonce and nomodule were ignored, but jQuery 3.4.0 now hangs onto them.

Radio elements: expected state in event handlers

We had already fixed the same issue with checkboxes, but accidentally left out radio inputs. In the following example, true was logged the first time the element was clicked. We fixed it so that the checked property is updated before the event handler is executed.

Example

var $radios = jQuery(".example");
var $firstRadio = $radios.first();
var firstCheckedState = $firstRadio.prop("checked");
$radio.on("click", function() {
  // true in <3.4.0
  console.log($firstRadio.prop("checked") === firstCheckedState);
});
$radios.eq(1).click();

Minor vulnerability fix: Object.prototype pollution

jQuery 3.4.0 includes a fix for some unintended behavior when using jQuery.extend(true, {}, ...). If an unsanitized source object contained an enumerable __proto__ property, it could extend the native Object.prototype. This fix is included in jQuery 3.4.0, but patch diffs exist to patch previous jQuery versions.

Example

jQuery.extend(true, {},
  JSON.parse('{"__proto__": {"test": true}}')
);
console.log( "test" in {} ); // true

Note that while jQuery does its best to protect users from security vulnerabilities, jQuery is a DOM manipulation library that will generally do what you tell it to do. In this case, the behavior was likely unexpected, so jQuery.extend will no longer write any properties named __proto__. But guards such as this one are not replacements for good security practices such as user input sanitization.

Deprecating positional selectors and the sunset of Sizzle

The basic API of jQuery is to select something and then do something with what was selected. Sizzle, the selector engine in jQuery, handles the first half. It’s been a fast and efficient little engine that has paved the way for native selector APIs like querySelectorAll and additional native JavaScript and CSS selectors. Now that many of these selectors have made their way into modern browsers, it’s almost time to say goodbye to Sizzle. But in order to remove Sizzle in jQuery 4.0, we will also need to remove what we refer to as positional selectors, which are non-standard selectors.

Specifically, jQuery 3.4.0 is deprecating :first, :last, :eq, :even, :odd, :lt, :gt, and :nth. When we remove Sizzle, we’ll replace it with a small wrapper around querySelectorAll, and it would be almost impossible to reimplement these selectors without a larger selector engine.

We think this trade-off is worth it. Keep in mind we will still support the positional methods, such as .first, .last, and .eq. Anything you can do with positional selectors, you can do with positional methods instead. They perform better anyway.

Upgrading

There should be no compatibility issues if upgrading from jQuery 3.0+. If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.4.0.js

https://code.jquery.com/jquery-3.4.0.min.js

You can also get this release from npm:

npm install jquery@3.4.0

Slim build

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:

https://code.jquery.com/jquery-3.4.0.slim.js

https://code.jquery.com/jquery-3.4.0.slim.min.js

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.

Thanks

Thank you to all of you who participated in this release by submitting patches, reporting bugs, or testing, including abnud1, Jason Bedard, buddh4, Kris Borchers, Andrei Fangli, Oleg Gaidarenko, Richard Gibson, Michal Golebiowski-Owczarek, Marja Hölttä, Dave Methvin, Ed S, Luis Emilio Velasco Sanchez, Saptak Sengupta, tmybr11, Bert Zhang, and the whole jQuery team.

Changelog

GitHub changelog: Issues fixed in 3.4.0 | All changes

Ajax

Core

  • Use isAttached to check for attachment of element (662083ed)
  • Tiny efficiency fix to jQuery.extend / jQuery.fn.extend (#4246) (#4245, 4ffb1df8)
  • Preserve CSP nonce on scripts with src attribute in DOM manipulation (#4323, 00504037)
  • Preserve CSP nonce on scripts in DOM manipulation (#3541, c7c2855e)
  • Support passing nonce through jQuery.globalEval (#4278, 5bdc85b8)
  • Recognize Shadow DOM in attachment checks (#3504, 9b77def5)
  • Prevent Object.prototype pollution for $.extend( true, … ) (753d591a)

CSS

  • Ensure camel- vs kebab-cased names are not collapsed for CSS vars (f8c1e902)
  • Avoid filling jQuery.cssProps (#3986, 2b5f5d5e)
  • Correctly detect scrollbox support with non-default zoom (#4029, 821bf343)
  • Don’t auto-append “px” to CSS variables (#4064) (#4063, 75b77b48)
  • Skip the px-appending logic for animations of non-element props (f5e36bd8)
  • Avoid forcing a reflow in width/height getters unless necessary (#4322, a0abd15b)
  • Don’t read styles.position in the width/height cssHook unless necessary (#4185, 354f6036)
  • Don’t auto-append “px” to possibly-unitless CSS grid properties (#4007, f997241f)

Dimensions

  • fix computing outerWidth on SVGs (#3964, e743cbd2)
  • avoid fetching boxSizing when setting width/height – this avoids forcing a reflow in some cases (#3991, 73d7e625)
  • fall back to offsetWidth/Height for border-box in IE (#4102, 315199c1)

Event

  • Prevent leverageNative from double-firing focusin (fe5f04de)
  • Add “code” property to Event object (#3978, 899c56f6)
  • Leverage native events for focus/blur/click; propagate additional data (#1741, #3423, #3751, #4139, 669f720e)
  • Respect script nomodule attribute in DOM manipulation (#4281, e4de8b46)
  • Restore _evalUrl jQuery.ajax calls to dataType: script (13de7c9e)
  • Only evaluate HTTP-successful script src (#4126, c2026b11)

Manipulation

  • Properly detect HTML elements with single-character names (#4124, 979809c5)

Misc

  • Add config for lockbot (2348f399)
  • Update license prolog/epilog to placate Github checker (29e76e25)

README

  • add gitter badge to README.md (7869f83d)
  • Add FOSSA license scan status badge (45f08588)

Selector

Serialize

  • jQuery.param: return empty string when given null/undefined (#2633, 0645099e)

Traversing

Internal

  • Seasonal update of uglify and its options (09684ba3)
  • Remove unnecessary ESLint exception (dc05f3c1)
  • Run the basic test suite in jsdom (0ec25abb)
  • Remove manual QUnit fixture resetting (84b6a0be)
  • Make Promises/A+ tests use the dot reporter instead of the default (ca9356ec)
  • Update QUnit from 1.23.1 to 2.9.2 (6ced2639)
  • Run Karma browser tests on Node.js 10 instead of 8 (16ad9889)
  • Update jsdom; migrate a test with Symbol polyfill to an iframe test (9cb124ed)
  • Remove obsolete globals from ESLint configuration (c10945d0)
  • Update most dependencies (8751e9ef)
  • Update test code for compatibility with QUnit 2.x (#4297) (c3498187)
  • Advise to create test cases on JS Bin or CodePen, drop JSFiddle (da44ff39)

Bad map file for jQuery 1.9.1 in the jQuery CDN

Posted on by

Quite a while back, Mike Taylor pointed out that the jQuery CDN has a minified copy of jQuery 1.9.1 with an incorrect map file reference. Basically, it refers to the map for jQuery 1.11.1, and that’s just wrong. If you are trying to debug a site that uses the minified jQuery 1.9.1 file, dev tools will get very confused and make a hard job even harder.

You might think that we could just edit the https://code.jquery.com/jquery-1.9.1.min.js file to point to the correct map file, which does exist as https://code.jquery.com/jquery-1.9.1.min.map. There are at least two problems with doing that. The first is that the file is heavily cached across the internet, since it’s been assumed for years that it will never change once the release occurs. Even if we edited the file, both the JavaScript and map file might never actually update at the point where they’re being used.

A second problem is even more serious. We’ve been advocating that developers use the script’s integrity attribute to ensure that the file you are including has not been modified since you originally wrote the script tag. If we modify the contents of the file this attribute will be wrong and the page will no longer include the file. This is likely to completely break the page! Given the age of jQuery 1.9.1 it is possible that many of the pages including this file are not being actively maintained. Thus, we can’t seriously consider changing the JavaScript file in any way, not even one byte.

The least disruptive option is to remove the jquery.min.map file that the jQuery 1.9.1 minified file references. It does not affect whether jQuery runs correctly for the visitors of a site. It only has the effect of disabling the source map. Because of these pitfalls of including the sourceMappingURL map reference in CDN JavaScript files that are often copied elsewhere, we no longer include it.

If you need to debug a site using one of these minified files, it is possible to manually associate a map file in Chrome. Open the minified source file, right click over the area of the minified source, and select “Add source map…”.

The incorrect jquery.min.map file has been removed from the jQuery CDN. We expect that there won’t be any observable change from removing this file, other than restoring sanity to debugging a site that uses jQuery 1.9.1. The jQuery 1.11.1 minified file does not reference its map, so it will continue to work fine and you can associate a map file as mentioned above.

Because caches are so aggressive on CDNs and across the internet, it’s possible that you may still see this map file for a while. If you see some unusual behavior that you think is related to the missing jquery.min.map file you can open a ticket on the CDN issue tracker.

jQuery 3.3.1 – fixed dependencies in release tag

Posted on by

We encountered an issue in the release for jQuery 3.3.0, so we’ve immediately released another tag. The code itself is identical, but our release dependencies (only used during release) were added to the dependencies of the jQuery package itself due to the new behavior of npm in version 5+.

jQuery 3.3.1 is now recommended if installing from npm or GitHub. If using jQuery on any CDN, the built file only differs in the version number.

We apologize for any inconvenience and have updated our release script to account for this issue.

Please see the jQuery 3.3.0 blog post for all relevant code changes in this release.

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.3.1.js

https://code.jquery.com/jquery-3.3.1.min.js

You can also get this release from npm:

npm install jquery@3.3.1

Slim build

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 all your 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 – 24k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.3.1.slim.js
https://code.jquery.com/jquery-3.3.1.slim.min.js

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.

jQuery 3.3.0 – A fragrant bouquet of deprecations and…is that a new feature?

Posted on by

It’s been a while since the last jQuery release, but the Core team hasn’t been idle. We’ve got an all new minor release for you, and it’s even got a new feature in it!

The .addClass(), .removeClass(), and .toggleClass() methods now accept an array of classes.


jQuery(elem).addClass([
   'dave', 'michał', 
   'oleg', 'richard', 
   'jason', 'timmy'
]);

Generally, jQuery is not looking to add anything new. We tend to focus more on what we can remove rather than what we can add. But as soon as we saw this feature request, we wondered how it hadn’t been added before.

There should be no compatibility issues if upgrading from jQuery 3.0+. If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

Deprecations

We’ve pruned some roses, lilies, and sunflowers in this release. Some of these will smell sweeter than others, but put them together, and you’ve got a beautiful bouquet of…depre-carnations.

These functions have either lost some of their usefulness over time, are considered to be less favorable than available alternatives, or were intended for internal usage from the beginning. While most of these will be removed in jQuery 4.0, it’s worth noting that we do not consider the deprecation of a method to mean that it will be removed; it means that we encourage the use of alternatives. For instance, event aliases like .click() will likely never be removed.

Command-line Testing

The magnificent Timo Tijhof has made it possible to run all jQuery tests on the command line, using grunt and karma. This is something we’ve always wanted but it was complicated by our need for a php server to run ajax tests. Thanks to Timo for making it happen!

Note: jQuery no longer runs any tests on PhantomJS 1.x.

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.3.0.js

https://code.jquery.com/jquery-3.3.0.min.js

You can also get this release from npm:

npm install jquery@3.3.0

Slim build

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 all your 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 – 24k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.3.0.slim.js
https://code.jquery.com/jquery-3.3.0.slim.min.js

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.

Thanks

Thank you to all of you who participated in this release by submitting patches, reporting bugs, or testing, including Andreas Solledar, Basil Belokon, Boom Lee, “CDAGaming”, Dave Methvin, Erik Lax, Henry Zhu, Jason Bedard, Jordan Beland, Matan Kotler-Berkowitz, Michał Gołębiowski-Owczarek, Nilton Cesar, Pierre Spring, Richard Gibson, Saptak Sengupta, Shashanka Nataraj, Steve Mao, Timo Tijhof, Faisal Irfan Yar Khan, and the whole jQuery team.

 

Changelog

GitHub changelog: Issues fixed in 3.3.0 | All changes

Ajax

  • Add an ontimeout handler to all requests (#3586, 262acc6f)
  • Don’t process non-string data property on no-entity-body requests (#3438, d7237896)

Attributes

  • Feature: Allow array param in add/remove/toggleClass (#3532, 80f57f8a)

Build

  • Test on Node.js 8, stop testing on Node.js 7 (bef46a2a)
  • Update to Babel 7, use for-of plugin instead of preset-es2015 (90bac40a)
  • Remove package-lock.json, add it to .gitignore (#3792, 7037facc)
  • Test on Node.js 9 (3e902a81)
  • Fix UglifyJS output in Android 4.0; update uglify (#3743, c9efd11f)

Core

CSS

  • Drop the float mapping from cssProps (bbf33428)
  • Correctly set support properties with non-default zoom (#3808, f00a0759)
  • Detect more WebKit styles erroneously reported as percentages (#3777, 94ddf620)
  • Retrieve inline style before computed (c4598da4)
  • Avoid unit-conversion interference from CSS upper bounds (#2144, 692f9d4d)

Deferred

Dimensions

Docs

  • Create CODE_OF_CONDUCT.md (e84d3bc0)
  • Update links to HTML spec for stripAndCollapse (#3594) (e1b1b2d7)

Event

Filter

Manipulation

  • Use `.children` to select tbody elements (a88b48ea)
  • Add support for scripts with module type (#3871, 5d3a968e)

Offset

Support

jQuery 3.2.1 Is Now Available, With Some Hotfixes

Posted on by

jQuery 3.2.1 is now available! This release comes with some hotfixes for regressions that were introduced in the 3.2.0 build four days ago. We wanted to release this patch as quickly as possible to squash any bugs you may have experienced when upgrading. The most significant one had to do with retrieving width or height on an inline element with no explicitly-set dimensions. This should now work as expected. A full list of changes is available below. Also see the 3.2.0 blog post for the bug fixes and improvements that still apply if upgrading from jQuery 3.1.1.

There should be no compatibility issues if upgrading from jQuery 3.0+. If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

Changes

Core

  • Ensure jQuery.holdReady is in the right place (#3573, fcc9a9ec)

Dimensions

  • Ensure we get proper values for width and height on elements with display “inline” (#3571, 473d2ea7)

Event

  • Ensure trigger data is passed to radio click event handlers (#3579, a6b07052)
  • Revert: Trigger checkbox and radio click events identically (35785a32).
  • Revert: Add radio click triggering tests (4d6b4536).

GitHub changelog: Issues fixed in 3.2.1 | All changes

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.2.1.js

https://code.jquery.com/jquery-3.2.1.min.js

You can also get this release from npm:

npm install jquery@3.2.1

Slim build

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 all your 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 – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.2.1.slim.js
https://code.jquery.com/jquery-3.2.1.slim.min.js

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.

Thanks

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Steve Mao and the whole jQuery team.

jQuery 3.2.0 Is Out!

Posted on by

jQuery 3.2.0 has been released!

This release includes some bug fixes, improvements, and some deprecations. There should be no compatibility issues if upgrading from jQuery 3.0+.

If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

Notable Updates

  • Added support for custom CSS properties (#3144).
  • Deprecated jQuery.holdReady (#3288).
  • Deprecated jQuery.nodeName (#3475).
  • Deprecated jQuery.isArray (#2961).
  • Fixed a bug in .width(), .height(), and related methods where CSS transforms were included in the calculations. For instance, an element with the style transform: scale(2x) should not have its width and height values doubled (#3193).
  • Added support for <template> elements to the .contents() method (#3436).
  • Added back the deprecated module to the slim build. This change is largely insignificant given the module’s small size. We believe it makes more sense to remove deprecated pieces from the slim build at the same time as the main jQuery build (#3237).

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.2.0.js

https://code.jquery.com/jquery-3.2.0.min.js

You can also get this release from npm:

npm install jquery@3.2.0

Slim build

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 all your 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 – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.2.0.slim.js
https://code.jquery.com/jquery-3.2.0.slim.min.js

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.

Thanks

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Connor Atherton, Jason Bedard, David Broder-Rodgers, Oleg Gaidarenko, Michał Gołębiowski, Richard Gibson, karan-96, Manoj Kumar, Alexander Lisianoi, Alex Louden, Alex Padilla, and the whole jQuery team.

GitHub changelog: Issues fixed in 3.2.0 | All changes

Full changelog

Callbacks

  • Prevent add() from unlocking with-memory lists (#3469, 9d822bc1)

Core

CSS

Deferred

  • Stop inventing jQuery.when() resolution values (#3442, 5d79c646)

Dimensions

  • Ignore transforms when retrieving width/height (#3193, c920ff6e)

Docs

  • Remove supported jQuery versions from ISSUE_TEMPLATE.md (fedc1aa6)
  • Correct typo in issue template (a8816caf)

Effects

Event

  • Trigger checkbox and radio click events identically (#3423, b442abac)
  • Add radio click triggering tests (5f35b5b4)

Manipulation

Offset

Tests

  • Skip CSS custom properties tests in non-supporting browsers (bcec54ee)
  • Update the loader so test pages always get jQuery (14b393d0)
  • Added tests for symbol-separated tag names (#2006, bd9145fa)
  • Clean up after the CSS Custom Properties support test (fc34dbc2)

Traversing

Build

  • Run tests on Node.js 7 (7bb62bb3)
  • Stop testing on Node.js 0.10 (5b4cb0d3)
  • jQuery Foundation -> JS Foundation (7fbab881)
  • Make the @CODE-replacing regex more robust (4e509677)
  • ESLint setup improvements (cbc8638c)
  • Drop jscs.json from .npmignore (b3e0a560)
  • Add most of the dist folder to .eslintignore (1754e315)
  • Use valid ecmaVersion (8cb4cd71)
  • Drop support for building on Node.js 0.12 (d10ac0e5)
  • Fix tests in AMD mode (56136897)
  • Fix markerPattern and ticketPattern regexes in package.json (25c6a0a2)
  • Keep deprecated module in slim (#3237, 0588d0ce)

jQuery 3.1.1 Released!

Posted on by

jQuery 3.1.1 is now available!

This release includes some bug fixes and improvements. As with all patch version releases, there are no new features or intended compatibility issues (if upgrading from jQuery 3.0+) in this release.

We fixed a selector issue with disabled options, exposed jQuery.noConflict even when jQuery is loaded with AMD, and fixed some issues concerning whitespace. We also fixed an issue with the map file that will help when using CDN copies during debugging.

If you haven’t yet upgraded to jQuery 3+, please have a look at the 3.0 Upgrade Guide. The jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code.

Please try out this new release and let us know about any issues you experienced.

GitHub changelog: Issues fixed in 3.1.1 | All changes

Download

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.1.1.js

https://code.jquery.com/jquery-3.1.1.min.js

You can also get this release from npm:

npm install jquery@3.1.1

Slim build

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 all your 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. All in all, it excludes ajax, effects, and currently deprecated code. 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 – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.1.1.slim.js
https://code.jquery.com/jquery-3.1.1.slim.min.js

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.

Thanks

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Michał Gołębiowski, Richard Gibson, Alexander Lisianoi, Steve Mao, Dave Methvin, and the whole jQuery team.

jQuery 3.1.0 Released – No More Silent Errors

Posted on by

Not so long ago, we released jQuery 3.0. One of the major features of jQuery 3.0 was a small rewrite of jQuery Deferreds. Specifically, we made them compatible with the Promises/A+ spec. That basically meant that errors had to be silenced and passed as rejection values to rejection handlers (added using deferred.catch()). This had the advantage of preventing Promise handlers from getting blocked up by runtime errors, but the disadvantage of errors being silenced if no rejection handlers were added. While this was the right move for Deferreds, we had also changed jQuery.ready and jQuery.fn.ready to use the new spec-compliant Deferreds under the covers.

Unfortunately, if you were using the usual ways to attach ready handlers (e.g. jQuery(function() {}) and jQuery(document).ready(function() {})), you had no way to add a rejection handler. Plus, it wasn’t obvious that you were in Deferred land. Any runtime exceptions were getting swallowed and lost in space. I think they ended up somewhere near Pluto, which isn’t even a planet anymore! There were workarounds, but this wasn’t acceptable to us.

We immediately set out to fix this, and thus jQuery 3.1.0 was born. No longer will errors be silent! You will see them logged to the console by default. If you’d like to have more control on how these errors are handled, we also added an entry point: jQuery.readyException. In most cases, you won’t need to use it, but any errors that are thrown within a ready handler will get passed to this function should you need it.

jQuery.readyException =
  function(error) {
    // "error" is thrown from
    // any ready handler
  };

The default jQuery.readyException will re-throw the error asynchronously, to avoid stopping execution and log the error to the console. We hope this solves any debugging issues you may have experienced when using jQuery 3.0.

We do not expect this release to have any breaking changes, but if you do encounter bugs in upgrading from the previous version, please let us know.

If you’d like help upgrading from jQuery 1.x or 2.x to jQuery 3.0, please check out the 3.0 Upgrade Guide and the jQuery Migrate 1.4.1 blog post.

3.1.0GitHub changelog

Download

You can include these files directly from the jQuery CDN if you like, or copy them to your own local server.

https://code.jquery.com/jquery-3.1.0.js
https://code.jquery.com/jquery-3.1.0.min.js

Slim build

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 all your 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. All in all, it excludes ajax, effects, and currently deprecated code. 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 – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.1.0.slim.js
https://code.jquery.com/jquery-3.1.0.slim.min.js

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.

Many thanks to all of you who participated in this release by testing, reporting bugs, or submitting patches, including Oleg Gaidarenko, Micha? Go??biowski, and the whole jQuery team.

jQuery 3.0 Final Released!

Posted on by

jQuery 3.0 is now released! This version has been in the works since October 2014. We set out to create a slimmer, faster version of jQuery (with backwards compatibility in mind). We’ve removed all of the old IE workarounds and taken advantage of some of the more modern web APIs where it made sense. It is a continuation of the 2.x branch, but with a few breaking changes that we felt were long overdue. While the 1.12 and 2.2 branches will continue to receive critical support patches for a time, they will not get any new features or major revisions. jQuery 3.0 is the future of jQuery. If you need IE6-8 support, you can continue to use the latest 1.12 release.

Despite the 3.0 version number, we anticipate that these releases shouldn’t be too much trouble when it comes to upgrading existing code. Yes, there are a few “breaking changes” that justified the major version bump, but we’re hopeful the breakage doesn’t actually affect that many people.

To assist with upgrading, we have a brand new 3.0 Upgrade Guide. And the jQuery Migrate 3.0 plugin will help you to identify compatibility issues in your code. Your feedback on the changes will help us greatly, so please try it out on your existing code and plugins!

You can get the files from the jQuery CDN, or link to them directly:

https://code.jquery.com/jquery-3.0.0.js

https://code.jquery.com/jquery-3.0.0.min.js

You can also get the release from npm:

npm install jquery@3.0.0

In addition, we’ve got the release for jQuery Migrate 3.0. We highly recommend using this to address any issues with breaking changes in jQuery 3.0. You can get those files here:

https://code.jquery.com/jquery-migrate-3.0.0.js

https://code.jquery.com/jquery-migrate-3.0.0.min.js

npm install jquery-migrate@3.0.0

For more information about upgrading your jQuery 1.x and 2.x pages to jQuery 3.0 with the help of jQuery Migrate, see the jQuery Migrate 1.4.1 blog post.

Slim build

Finally, we’ve added something new to this release. 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 all your web animations. Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a “slim” version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code. 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 – 23.6k vs 30k. These files are also available in the npm package and on the CDN:

https://code.jquery.com/jquery-3.0.0.slim.js

https://code.jquery.com/jquery-3.0.0.slim.min.js

This build was created with our custom build API, which allows you to exclude or include any modules you like. For more information, have a look at the jQuery README.
 

Compatibility with jQuery UI and jQuery Mobile

While most things will work, there are a few issues that jQuery UI and jQuery Mobile will be addressing in upcoming releases. If you find an issue, keep in mind that it may already be addressed upstream and using the jQuery Migrate 3.0 plugin should fix it. Expect releases soon.

 

Major changes

Below are just the highlights of the major new features, improvements, and bug fixes in these releases, you can dig into more detail on the 3.0 Upgrade Guide. A complete list of issues fixed is available on our GitHub bug tracker. If you read the blog post for 3.0.0-rc1, the below features are the same.

jQuery.Deferred is now Promises/A+ compatible

jQuery.Deferred objects have been updated for compatibility with Promises/A+ and ES2015 Promises, verified with the Promises/A+ Compliance Test Suite. This meant we needed some major changes to the .then() method. Legacy behavior can be restored by replacing any use of .then() with the now-deprecated .pipe() method (which has an identical signature).

  1. An exception thrown in a .then() callback now becomes a rejection value. Previously, exceptions bubbled all the way up, aborting callback execution. Any deferreds relying on the resolution of the deferred that threw an exception would never have resolved.

  2. Example: uncaught exceptions vs. rejection values

    
    var deferred = jQuery.Deferred();
    deferred.then(function() {
      console.log("first callback");
      throw new Error("error in callback");
    })
    .then(function() {
      console.log("second callback");
    }, function(err) {
      console.log("rejection callback", err instanceof Error);
    });
    deferred.resolve();
    

    Previously, “first callback” was logged and the error was thrown. All execution was stopped. Neither “second callback” nor “rejection callback” would have been logged. The new, standards-compliant behavior is that you’ll now see “rejection callback” and true logged. err is the rejection value from the first callback.


  3. The resolution state of a Deferred created by .then() is now controlled by its callbacks—exceptions become rejection values and non-thenable returns become fulfillment values. Previously, returns from rejection handlers became rejection values.

  4. Example: returns from rejection callbacks

    
    var deferred = jQuery.Deferred();
    deferred.then(null, function(value) {
      console.log("rejection callback 1", value);
      return "value2";
    })
    .then(function(value) {
      console.log("success callback 2", value);
      throw new Error("exception value");
    }, function(value) {
      console.log("rejection callback 2", value);
    })
    .then(null, function(value) {
      console.log("rejection callback 3", value);
    });
    deferred.reject("value1");
    

    Previously, this would log “rejection callback 1 value1”, “rejection callback 2 value2”, and “rejection callback 3 undefined”.

    The new, standards-compliant behavior is that this will log “rejection callback 1 value1”, “success callback 2 value2″, and “rejection callback 3 [object Error]”.


  5. Callbacks are always invoked asynchronously, even if a Deferred has already been resolved. Previously, these callbacks were executed synchronously upon binding.

  6. Example: async vs sync

    
    var deferred = jQuery.Deferred();
    deferred.resolve();
    deferred.then(function() {
      console.log("success callback");
    });
    console.log("after binding");
    

    Previously, this would log “success callback” then “after binding”. Now, it will log “after binding” and then “success callback”.


Important: while caught exceptions had advantages for in-browser debugging, it is far more declarative (i.e. explicit) to handle them with rejection callbacks. Keep in mind that this places the responsibility on you to always add at least one rejection callback when working with promises. Otherwise, some errors might go unnoticed.

We’ve built a plugin to help in debugging Promises/A+ compatible Deferreds. If you are not seeing enough information about an error on the console to determine its source, check out the jQuery Deferred Reporter Plugin.

jQuery.when has also been updated to accept any thenable object, which includes native Promise objects.

https://github.com/jquery/jquery/issues/1722
https://github.com/jquery/jquery/issues/2102

Added .catch() to Deferreds

The catch() method was added to promise objects as an alias for .then(null, fn).

https://github.com/jquery/jquery/issues/2102

Error cases don’t silently fail

Perhaps in a profound moment you’ve wondered, “What is the offset of a window?” Then you probably realized that is a crazy question – how can a window even have an offset?

In the past, jQuery has sometimes tried to make cases like this return something rather than having them throw errors. In this particular case of asking for the offset of a window, the answer up to now has been { top: 0, left: 0 } With jQuery 3.0, such cases will throw errors so that crazy requests aren’t silently ignored. Please try out this release and see if there is any code out there depending on jQuery to mask problems with invalid inputs.

https://github.com/jquery/jquery/issues/1784

Removed deprecated event aliases

.load, .unload, and .error, deprecated since jQuery 1.8, are no more. Use .on() to register listeners.

https://github.com/jquery/jquery/issues/2286

Animations now use requestAnimationFrame

On platforms that support the requestAnimationFrame API, which is pretty much everywhere but IE9 and Android<4.4, jQuery will now use that API when performing animations. This should result in animations that are smoother and use less CPU time – and save battery as well on mobile devices.

jQuery tried using requestAnimationFrame a few years back but there were serious compatibility issues with existing code so we had to back it out. We think we’ve beaten most of those issues by suspending animations while a browser tab is out of view. Still, any code that depends on animations to always run in nearly real-time is making an unrealistic assumption.

Massive speedups for some jQuery custom selectors

Thanks to some detective work by Paul Irish at Google, we identified some cases where we could skip a bunch of extra work when custom selectors like :visible are used many times in the same document. That particular case is up to 17 times faster now!

Keep in mind that even with this improvement, selectors like :visible and :hidden can be expensive because they depend on the browser to determine whether elements are actually displaying on the page. That may require, in the worst case, a complete recalculation of CSS styles and page layout! While we don’t discourage their use in most cases, we recommend testing your pages to determine if these selectors are causing performance issues.

This change actually made it into 1.12/2.2, but we wanted to reiterate it for jQuery 3.0.

https://github.com/jquery/jquery/issues/2042

As mentioned above, the Upgrade Guide is now available for anyone ready to try out this release. Aside from being helpful in upgrading, it also lists more of the notable changes.

 

Thanks

Thank you to everyone who helped with this release through code contributions, issue reports, and more, including but not limited to Jason Bedard, Fredrik Blomqvist, Leonardo Braga, Ralin Chimev, Jon Dufresne, Oleg Gaidarenko, Richard Gibson, Michał Gołębiowski, Scott González, Zack Hall, Alexander K, Martijn W. van der Lee, Alexander Lisianoi, Steve Mao, Dave Methvin, Jha Naman, Jae Sung Park, Todor Prikumov, William Robinet, Felipe Sateler, Damian Senn, Josh Soref, Jun Sun, Christophe Tafani-Dereeper, Vitaliy Terziev, Joe Trumbull, Bernhard M. Wiedemann, Devin Wilson, and Henry Wong.

 

Changelog

Ajax

  • Golf away 21 bytes (eaa3e9f)
  • Preserve URL hash on requests (#1732, e077ffb)
  • Execute jQuery#load callback with correct context (#3035, 5d20a3c)
  • Ensure ajaxSettings.traditional is still honored (#3023, df2051c)
  • Remove unnecessary use of jQuery.trim (0bd98b1)

Attributes

  • Avoid infinite recursion on non-lowercase attribute getters (#3133, e06fda6)
  • Add a support comment & fix a link @ tabIndex hook (9cb89bf)
  • Strip/collapse whitespace for set values on selects (#2978, 7052698)
  • Remove redundant parent check (b43a368)
  • Fix setting selected on an option in IE<=11 (#2732, 780cac8)

CSS

  • Don’t workaround the IE 11 iframe-in-fullscreen sizing issues (#3041, ff1a082)
  • Toggle detached elements as visible unless they have display: none (#2863, 755e7cc)
  • Make sure elem.ownerDocument.defaultView is not null (#2866, 35c3148)
  • Add animation-iteration-count to cssNumber (#2792, df822ca)
  • Restore cascade-override behavior in .show (#2654, #2308, dba93f7)
  • Stop Firefox from treating disconnected elements as cascade-hidden (#2833, fe05cf3)

Core

Deferred

  • Separate the two paths in jQuery.when (#3029, 356a3bc)
  • Provide explicit undefined context for jQuery.when raw casts (#3082, 7f1e593)
  • Remove default callback context (#3060, 7608437)
  • Warn on exceptions that are likely programming errors (#2736, 36a7cf9)
  • Propagate progress correctly from unwrapped promises (#3062, d5dae25)
  • Make jQuery.when synchronous when possible (#3100, de71e97)
  • Remove undocumented progress notifications in $.when (#2710, bdf1b8f)
  • Give better stack diagnostics on exceptions (07c11c0)

Dimensions

  • Add tests for negative borders & paddings (f00dd0f)

Docs

  • Fix various spelling errors (aae4411)
  • Update support comments related to IE (693f1b5)
  • Fix an incorrect comment in the attributes module (5430c54)
  • Updated links to https where they are supported. (b0b280c)
  • Update support comments to follow the new syntax (6072d15)
  • Use https where possible (1de8346)
  • Use HTTPS URLs for jsfiddle & jsbin (63a303f)
  • Add FAQ to reduce noise in issues (dbdc4b7)
  • Add a note about loading source with AMD (#2714, e0c25ab)
  • Add note about code organization with AMD (#2750, dbc4608)
  • Reference new feature guidelines and API tenets (#2320, 6054139)

Effects

Event

  • Allow constructing a jQuery.Event without a target (#3139, 2df590e)
  • Add touch event properties, eliminates need for a plugin (#3104, f595808)
  • Add the most commonly used pointer event properties (7d21f02)
  • Remove fixHooks, propHooks; switch to ES5 getter with addProp (#3103, #1746, e61fccb)
  • Make event dispatch optimizable by JavaScript engines (9f268ca)
  • Evaluate delegate selectors at add time (#3071, 7fd36ea)
  • Cover invalid delegation selector edge cases (e8825a5)
  • Fix chaining .on() with null handlers (#2846, 17f0e26)
  • Remove pageX/pageY fill for event object (#3092, 931f45f)

Events

  • Don’t execute native stop(Immediate)Propagation from simulation (#3111, 94efb79)

Manipulation

Offset

  • Resolve strict mode ClientRect “no setter” exception (3befe59)

Selector

Serialize

  • Treat literal and function-returned null/undefined the same (#3005, 9fdbdd3)
  • Reduce size (91850ec)

Support

Tests

  • Take Safari 9.1 into account (234a2d8)
  • Limit selection to #qunit-fixture in attributes.js (ddb2c06)
  • Set Edge’s expected support for clearCloneStyle to true (28f0329)
  • Fix Deferred tests in Android 5.0’s stock Chrome browser & Yandex.Browser (5c01cb1)
  • Add additional test for jQuery.isPlainObject (728ea2f)
  • Build: update QUnit and fix incorrect test (b97c8d3)
  • Fix manipulation tests in Android 4.4 (0b0d4c6)
  • Remove side-effects of one attributes test (f9ea869)
  • Account for new offset tests (f52fa81)
  • Make iframe tests wait after checking isReady (08d73d7)
  • Refactor testIframe() to make it DRYer and more consistent (e5ffcb0)
  • Weaken sync-assumption from jQuery.when to jQuery.ready.then (f496182)
  • Test element position outside view (#2909, a2f63ff)
  • Make the regex catching Safari 9.0/9.1 more resilient (7f2ebd2)

Traversing

  • .not/.filter consistency with non-elements (#2808, 0e2f8f9)
  • Never let .closest() match positional selectors (#2796, a268f52)
  • Restore jQuery push behavior in .find (#2370, 4d3050b)