Updating to jQuery 3

Following jQuery in Version 2.2.4. has security vulnerabilities
We are going to update to jQuery 3. (Fixes #37382 - Update to jQuery 3)

Most of the work was around updating select2 package, and our usage of that. The select2 work was only needed for foreman core and should not effect plugins if they are using the foreman core select functions (form_select_f, select_f).

Some plugin work is needed to fix deprecated functions, but from what I saw in plugins its pretty straight forward. Plugins can use GitHub - jquery/jquery-migrate: A development tool to help migrate away from APIs and features that have been or will be removed from jQuery core to migrate.
The deprecated things I saw in our plugins are:

  • document.execCommand("copy"); should use navigator.clipboard.writeText(text);
  • $.cookie(cookieName);tfm.Cookies.get(cookieName);
  • .ACTION (.submit, .click, .change(), etc) → .trigger("ACTION); (.trigger("click");
  • .change(foo).on("change",foo)
  • .bind.on
  • .onbind.off
  • .size().length
  • jQuery.parseJSON - > JSON.parse

There might be more, please check the migration guide for jquery 2 → 3

4 Likes