2019-16 - jQuery 3 Migration

Project Description

WET 4.x will include an upgrade to jQuery 3.3.1. This page is being used to coordinate testing, develop code, and document the work that needs to be done to perform the upgrade. Apart from the research listed below, we’ve also attached some useful links to official jQuery upgrade guides, if you needed more information.

On this page

Good to know

Versions and migrate plugin

We’re upgrading jQuery from version 2.2.4 to 3.3.1. During testing, we will include the jQuery migrate plugin 3.0.1 to simplify the upgrade. The migrate plugin will allow us to identify any deprecated features in use so that we can update the WET code to run properly on the upgraded jQuery. However, the migrate plugin is a temporary solution for testing and development purposes only, and the migrate plugin will be removed when the upgrade is launched.

Security issues

The major issue here is that jQuery 2.2.4 is no longer being patched or supported.

jQuery upgrade guide

We’d recommend that you have a look at the official jQuery change log and upgrade guide to get an idea of all the important changes and have some accurate information on hand if something is not clear.

Source Code Changes

The following list of commits are the cummulative proposed changes to migrate the repo to jQuery 3

Test plan

Development Site

The following links are to the development site (latest build to my jquery3-migration branch) and a link directly to the branch code:

Status Descriptions

Not yet started

No testing or coding work has commenced.

On hold

Testing or coding work previously started, but for some reason has stopped.

In Progress

Currently testing or addressing coding issues.

Closed

Code has been tested and if any code modifications were required they have been implemented and tested.

WET Plugins

Name jQuery Migrate Console Error Console Error Messages Notes Code Change Req'd Status
Calendar of Events - jQuery 3 version (Calendar of Events - jQuery v2 version) Yes
  • jQuery.fn.removeAttr no longer sets boolean properties: disabled
  • removeAttr isn't necessarily an issue - has to be manually checked
No Closed
Charts and graphs - jQuery 3 version (Charts and graphs - jQuery v2 version) Yes No error descriptions
  • Potential issues with flot
No On hold
Collapsible alerts - jQuery 3 version (Collapsible alerts - jQuery v2 version) No No error descriptions No notes No Closed
Country Content - jQuery 3 version (Country Content - jQuery v2 version) Yes
  • Blocked loading mixed active content "http://freegeoip.net/shutdown"
  • This is not a jQuery 3 thing
  • The freegeoip service has been deprecated and so this plugin can't be used anymore
No Closed
Data Ajax - jQuery 3 version (Data Ajax - jQuery v2 version) No No error descriptions No notes No Closed
Data Inview - jQuery 3 version (Data Inview - jQuery v2 version) No No error descriptions No notes No Closed
Data Picture - jQuery 3 version (Data Picture - jQuery v2 version) No No error descriptions No notes No Closed
Dismissable content - jQuery 3 version (Dismissable content - jQuery v2 version) No
No notes No Closed
Equal height - jQuery 3 version (Equal height - jQuery v2 version) No No error descriptions No notes No Closed
Facebook embedded pages - jQuery 3 version (Facebook embedded pages - jQuery v2 version) Not yet started
Favicon - jQuery 3 version (Favicon - jQuery v2 version) No No error descriptions No notes No Closed
Feeds - jQuery 3 version (Feeds - jQuery v2 version) No
  • jQuery.fn.removeAttr no longer sets boolean properties: open
  • removeAttr isn't necessarily an issue - has to be manually checked
No On hold
Filter - jQuery 3 version (Filter - jQuery v2 version) No No error descriptions No notes No Closed
Footnotes - jQuery 3 version (Footnotes - jQuery v2 version) No No error descriptions No notes No Closed
Form validation - jQuery 3 version (Form validation - jQuery v2 version) No No error descriptions No notes No Closed
Geomap - jQuery 3 version (Geomap - jQuery v2 version) Not yet started
Lightbox - jQuery 3 version (Lightbox - jQuery v2 version) Yes
  • jQuery.fn.focus() event shorthand is deprecated
  • focus() is not necessarily an issue - it is context dependend and needs further testing
No On hold
Menu - jQuery 3 version (Menu - jQuery v2 version) Yes
  • jQuery.fn.removeAttr no longer sets boolean properties
  • removeAttr isn't necessarily an issue - has to be manually checked
No On hold
Multimedia Player - jQuery 3 version (Multimedia Player - jQuery v2 version) Yes
  • 'ready' event is deprecated
  • Further research is required for this
No On hold
Overlay - jQuery 3 version (Overlay - jQuery v2 version) Yes
  • jQuery.fn.focus() event shorthand is deprecated
  • Error can be triggered by clicking the "Centered Popup" button
  • Further research is required for this
No On hold
Prettify - jQuery 3 version (Prettify - jQuery v2 version) No No error descriptions No notes No Closed
Session Timeout - jQuery 3 version (Session Timeout - jQuery v2 version) Yes
  • jQuery.fn.focus() event shorthand is deprecated
  • Further research is required for this
No On hold
Share widget - jQuery 3 version (Share widget - jQuery v2 version) Yes
  • jQuery.fn.focus() event shorthand is deprecated
  • Error can be triggered by clicking the "Share this" button
  • Further testing and understanding of this error is required
No On hold
Tabbed Interface - jQuery 3 version (Tabbed Interface - jQuery v2 version) Yes
  • jQuery.fn.removeAttr no longer sets boolean properties
  • removeAttr isn't necessarily an issue - has to be manually checked
No On hold
Tables - jQuery 3 version (Tables - jQuery v2 version) Yes
  • jQuery.fn.focus() event shorthand is deprecated
  • jQuery.fn.blur() event shorthand is deprecated
  • Errors can be triggered by using the table pagination functionality
No On hold
Text highlighting - jQuery 3 version (Text highlighting - jQuery v2 version) No No error descriptions No notes No Closed
Toggle - jQuery 3 version (Toggle - jQuery v2 version) No No error descriptions No notes No Closed
Twitter embedded timeline - jQuery 3 version (Twitter embedded timeline - jQuery v2 version) No No error descriptions No notes No Closed
Zebra striping - jQuery 3 version (Zebra striping - jQuery v2 version) No No error descriptions No notes No Closed

Canada.ca Theme Plugins

To do

Polyfills

Name jQuery Migrate Console Error Console Error Messages Notes Code Change Req'd Status
Datalist (autocomplete) - jQuery 3 version (Datalist (autocomplete) - jQuery v2 version) No No error descriptions
  • The example page of the Dynamic version of Datalist plugin doesn't seem to be working correctly
No Closed
Datalist (autocomplete) Dynamic - jQuery 3 version (Datalist (autocomplete) Dynamic - jQuery v2 version) Yes
  • Unable to get property 'isPersonal' of undefined or null reference
  • This is not a jQuery 3 error
No On hold
Details/summary - jQuery 3 version (Details/summary - jQuery v2 version) No No error descriptions No notes No Closed
Input (date picker) - jQuery 3 version (Input (date picker) - jQuery v2 version) No No error descriptions No notes No Closed
Input (slider control) - jQuery 3 version (Input (slider control) - jQuery v2 version) No No error descriptions No notes No Closed
MathML - jQuery 3 version (MathML - jQuery v2 version) No No error descriptions
  • Console warnings are present however they are from the MathML library
No Closed
Meter - jQuery 3 version (Meter - jQuery v2 version) No No error descriptions No notes No Closed
Progress - jQuery 3 version (Progress - jQuery v2 version) No No error descriptions No notes No Closed
events.js - jQuery 3 version (events.js - jQuery v2 version) No No error descriptions No notes No Closed
jawsariafixes.js - jQuery 3 version (jawsariafixes.js - jQuery v2 version) No No error descriptions No notes No Closed
svg.js - jQuery 3 version (svg.js - jQuery v2 version) No No error descriptions No notes No Closed

WET-BOEW JS Dependencies

To do

Breaking Changes

The following section lists all of the breaking changes that were introduced by jQuery 3.x.

Change Description: Special-case Deferred methods removed from jQuery.ajax Change Category: Ajax

The jqXHR object returned from jQuery.ajax() is a jQuery Deferred and has historically had three extra methods with names matching the arguments object of success, error, and complete. This often confused people who did not realize that the returned object should be treated like a Deferred. As of jQuery 3.0 these methods have been removed. As replacements, use the Deferred standard methods of done, fail, and always, or use the new then and catch methods for Promises/A+ compliance.

Change Description: Cross-domain script requests must be declared Change Category: Ajax

When making a request via jQuery.ajax() or jQuery.get() for a script on a domain other than the one that hosts the document, you must now explicitly specify dataType: "script" in the options. This prevents the possibility of an attack where the remote site delivers non-script content but later decides to serve a script that has malicious intent. Since jQuery.getScript() explicitly sets dataType: "script" it is unaffected by this change.

Change Description: Hash in a URL is preserved in a jQuery.ajax() call Change Category: Ajax

The jQuery.ajax() method no longer strips off the hash in the URL if it is provided, and sends the full URL to the transport (xhr, script, jsonp, or custom transport). If the server at the other end of the connection cannot deal with a hash on a URL, strip it off before sending the request.

Change Description: .removeAttr() no longer sets properties to false Change Category: Attributes

Lorem ipsum

Change Description: select-multiple with nothing selected returns an empty array Change Category: Attributes

Before jQuery 3.0, calling .val() on a <select multiple> element with no elements selected returned null. This was inconvenient since if at least one value was selected the return value would be an array. Also, if all options are disabled jQuery already returned an empty array. To improve consistency, the nothing-selected case now returns an empty array.

Change Description: jQuery 3.0 runs in Strict Mode Change Category: Core

Now that most of the browsers supported by jQuery 3.0 have "use strict", jQuery is being built with this directive. Your code is not required to run in Strict Mode, so most existing code should not require any changes. The one case we encountered three years ago was that ASP.NET 4.0 used arguments.caller.callee to attempt tracing through call stacks in its __doPostBack() method. If you are still using a version of ASP.NET that still does this, keep using jQuery 2.x or earlier. Modern browsers support stack traces via error.stack so it should not ever be necessary to examine arguments.caller.callee.

Change Description: document-ready handlers are now asynchronous Change Category: Core

Lorem ipsum

Change Description: jQuery.isNumeric() and custom .toString() Change Category: Core

Lorem ipsum

Change Description: Deprecated .context and .selector properties removed Change Category: Core

Lorem ipsum

Change Description: Deprecated .size() removed Change Category: Core

Lorem ipsum

Change Description: Undocumented internal methods no longer exposed Change Category: Core

Lorem ipsum

Change Description: Return values on empty sets are undefined Change Category: Core

Lorem ipsum

Change Description: .data() names containing dashes Change Category: Data

Lorem ipsum

Change Description: jQuery.Deferred is now Promises/A+ compatible Change Category: Deferred

Lorem ipsum

Change Description: jQuery.when() arguments Change Category: Deferred

Lorem ipsum

Change Description: jQuery.when() progress notifications Change Category: Deferred

Lorem ipsum

Change Description: .width(), .height(), .css("width"), and .css("height") can return non-integer values Change Category: Dimensions

Lorem ipsum

Change Description: .outerWidth() or .outerHeight() on window includes scrollbar width/height Change Category: Dimensions

Lorem ipsum

Change Description: .show(), .hide(), and .toggle() methods now respect more stylesheet changes Change Category: Effects

Lorem ipsum

Change Description: .load(), .unload(), and .error() removed Change Category: Event

Lorem ipsum

Change Description: .on("ready", fn) removed Change Category: Event

Lorem ipsum

Change Description: event.pageX and event.pageY normalization removed Change Category: Event

Lorem ipsum

Change Description: jQuery.event.props and jQuery.event.fixHooks removed Change Category: Event

Lorem ipsum

Change Description: Delegated events with bad selectors throw immediately Change Category: Event

Lorem ipsum

Change Description: .wrapAll(function) only calls the function once Change Category: Manipulation

Lorem ipsum

Change Description: Invalid input to the .offset() method Change Category: Offset

Lorem ipsum

Change Description: Behavior of :hidden and :visible Change Category: Selector

Lorem ipsum

Change Description: jQuery("#") and .find("#") are invalid syntax Change Category: Selector

Lorem ipsum

Change Description: jQuery.param() no longer converts %20 to a plus sign Change Category: Serialize

Lorem ipsum

Change Description: .andSelf() removed, use .addBack() Change Category: Serialize

The .andSelf() method was deprecated in jQuery 1.8 and now removed in 3.0 in favor of the .addBack() method, which does a better job of explaining what it does and also accepts an optional selector to filter what is added back.

To do

Future discussion topics

GitHub issue discussion

Out of scope

Usefulness of jQuery

There is a debate to be had about how useful jQuery is in today’s modern browser environments. Most modern browsers support newer JavaScript APIs which allow for complex query selection document.querySelectorAll https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll without a third party library like jQuery. These native JavaScript API calls will likely also be more performant than third party libraries as well.

Thankfully, the purpose of this research page is to determine the path forward for the upgrade to jQuery 3. Conversations about the future use of jQuery are out of scope for this project.