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
- Source code changes
- Test plan
- Future discussion topics
- GitHub issue discussion
- Out of scope
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.
- Summary of Important Changes
- jQuery Core 3.0 Upgrade Guide
- jQuery 3 Migrate Plugin
- jQuery 3 launch blog post
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 |
|
|
No | Closed |
Charts and graphs - jQuery 3 version (Charts and graphs - jQuery v2 version) | Yes | No error descriptions |
|
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 |
|
|
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 |
|
|
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 |
|
|
No | On hold |
Menu - jQuery 3 version (Menu - jQuery v2 version) | Yes |
|
|
No | On hold |
Multimedia Player - jQuery 3 version (Multimedia Player - jQuery v2 version) | Yes |
|
|
No | On hold |
Overlay - jQuery 3 version (Overlay - jQuery v2 version) | Yes |
|
|
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 |
|
|
No | On hold |
Share widget - jQuery 3 version (Share widget - jQuery v2 version) | Yes |
|
|
No | On hold |
Tabbed Interface - jQuery 3 version (Tabbed Interface - jQuery v2 version) | Yes |
|
|
No | On hold |
Tables - jQuery 3 version (Tables - jQuery v2 version) | Yes |
|
|
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 |
|
No | Closed |
Datalist (autocomplete) Dynamic - jQuery 3 version (Datalist (autocomplete) Dynamic - jQuery v2 version) | Yes |
|
|
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 |
|
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
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.
-
What do I search for?
jqXHR.success | error | complete
-
How do fix this?
Use the
Deferred
standard methods ofdone
,fail
, andalways
, or use the newthen
andcatch
methods for Promises/A+ compliance.
Change Description: Cross-domain script requests must be declared Change Category: Ajax
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.
-
What do I search for?
.ajax( | .get(
-
How do fix this?
If jQuery.ajax() or jQuery.get() tries to grab a script on a domain other than the one that hosts the document, you must now explicitly specify
dataType: "script"
in the options.
Change Description: Hash in a URL is preserved in a jQuery.ajax() call Change Category: Ajax
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.
-
What do I search for?
.ajax(
-
How do fix this?
This is not a potential issue because WET-BOEW doesn't communicate with any servers that can't handle a
#
in the URL
Change Description: .removeAttr() no longer sets properties to false Change Category: Attributes
-
What do I search for?
-
How do fix this?
Change Description: select-multiple with nothing selected returns an empty array Change Category: Attributes
.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.
-
What do I search for?
.val(
-
How do fix this?
TODO
Change Description: jQuery 3.0 runs in Strict Mode Change Category: Core
"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
.
-
What do I search for?
n/a
-
How do fix this?
n/a
Change Description: document-ready handlers are now asynchronous Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: jQuery.isNumeric() and custom .toString() Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: Deprecated .context and .selector properties removed Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: Deprecated .size() removed Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: Undocumented internal methods no longer exposed Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: Return values on empty sets are undefined Change Category: Core
-
What do I search for?
-
How do fix this?
Change Description: .data() names containing dashes Change Category: Data
-
What do I search for?
-
How do fix this?
Change Description: jQuery.Deferred is now Promises/A+ compatible Change Category: Deferred
-
What do I search for?
-
How do fix this?
Change Description: jQuery.when() arguments Change Category: Deferred
-
What do I search for?
-
How do fix this?
Change Description: jQuery.when() progress notifications Change Category: Deferred
-
What do I search for?
-
How do fix this?
Change Description: .width(), .height(), .css("width"), and .css("height") can return non-integer values Change Category: Dimensions
-
What do I search for?
-
How do fix this?
Change Description: .outerWidth() or .outerHeight() on window includes scrollbar width/height Change Category: Dimensions
-
What do I search for?
-
How do fix this?
Change Description: .show(), .hide(), and .toggle() methods now respect more stylesheet changes Change Category: Effects
-
What do I search for?
-
How do fix this?
Change Description: .load(), .unload(), and .error() removed Change Category: Event
-
What do I search for?
-
How do fix this?
Change Description: .on("ready", fn) removed Change Category: Event
-
What do I search for?
-
How do fix this?
Change Description: event.pageX and event.pageY normalization removed Change Category: Event
-
What do I search for?
-
How do fix this?
Change Description: jQuery.event.props and jQuery.event.fixHooks removed Change Category: Event
-
What do I search for?
-
How do fix this?
Change Description: Delegated events with bad selectors throw immediately Change Category: Event
-
What do I search for?
-
How do fix this?
Change Description: .wrapAll(function) only calls the function once Change Category: Manipulation
-
What do I search for?
-
How do fix this?
Change Description: Invalid input to the .offset() method Change Category: Offset
-
What do I search for?
-
How do fix this?
Change Description: Behavior of :hidden and :visible Change Category: Selector
-
What do I search for?
-
How do fix this?
Change Description: jQuery("#") and .find("#") are invalid syntax Change Category: Selector
-
What do I search for?
-
How do fix this?
Change Description: jQuery.param() no longer converts %20 to a plus sign Change Category: Serialize
-
What do I search for?
-
How do fix this?
Change Description: .andSelf() removed, use .addBack() Change Category: Serialize
.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.
-
What do I search for?
.andSelf(
-
How do fix this?
Use
.addBack()
instead
To do
- Investigate and determine what version of jQuery should go into the next version of WET (3.3.1 / slim vs other?)
- Investigate and determine what is the change list / breaking change list of jQuery 2.2.4 -> jQuery 3.3.1\
- Determine how many plugins WET has and put together a full list of dependencies that are being used
- Investigate with vulnerabilities impact jQuery 2.2.4, as well as if the offending code is used anywhere in WET
- Fork the documentation repo and add a placeholder page for the jQuery 3 Migration. All project documentation will go here.
- Create a GitHub issue in the main WET repo to facilitate a discussion for the upgrade
- Create a jquery3-migration branch in WET that pull requests will be added to
- Fork the newly created migration branch from WET and add the jquery migration plugin
- Investigate and determine the easiest way to add dist files to github pages or some web space (use a tool like travis, netlify, Jenkins to automagically send the dist files to the server)
Future discussion topics
- How do we do outreach on this mini project?
- Do we / should we get the Canada Digital team to spread the word?
- Do we tweet?
- Do we need a page that explains the impacts of the project – and once the project is done – what it means for those folks upgrading (especially the folks that have custom tools that leverage jquery 2.x)
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.