Skip to content

Upgrade jquery to v4#3730

Merged
lunkwill42 merged 29 commits intomasterfrom
chore/upgrade-jquery-to-v4
Feb 13, 2026
Merged

Upgrade jquery to v4#3730
lunkwill42 merged 29 commits intomasterfrom
chore/upgrade-jquery-to-v4

Conversation

@Simrayz
Copy link
Copy Markdown
Contributor

@Simrayz Simrayz commented Jan 26, 2026

Scope and purpose

Upgrade jQuery from 3.7.1 to 4.0.0.

Changes

  • Upgrade jQuery library to version 4.0.0
  • Replace deprecated jQuery APIs removed in v4:
    • $.parseJSON() -> JSON.parse()
    • $.trim() -> String.prototype.trim()
  • Add jQuery Migrate 4.0.2 shim for legacy plugins that still use deprecated APIs:
    • jquery-sparkline
    • jquery-tablesorter
    • DataTables

How to test

Open browser DevTools console and verify no JavaScript errors on:

  • PortAdmin (/portadmin/) - test saving port changes
  • Room Rack View (/search/room/<room>/) - verify sparklines render
  • IP Device Info (/ipdevinfo/<device>/) - verify sparklines render
  • Machine Tracker (/machinetracker/) - test table sorting, test with 10.0.0.0-10.0.1.255 as range, and 10000 days
  • SeedDB (/seeddb/) - test DataTables filtering/pagination (ip device tab)

jQuery Migrate logs warnings to console for deprecated API usage - these are expected for the legacy plugins.

Contributor Checklist

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ..."
  • Based this pull request on the correct upstream branch

@Simrayz Simrayz requested a review from a team January 26, 2026 19:19
@Simrayz Simrayz self-assigned this Jan 26, 2026
@Simrayz Simrayz added javascript dependencies Pull requests that update a dependency file labels Jan 26, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 26, 2026

Test results

    20 files      20 suites   24m 38s ⏱️
 2 864 tests  2 864 ✅ 0 💤 0 ❌
16 356 runs  16 356 ✅ 0 💤 0 ❌

Results for commit 52c74a8.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 78.12500% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.27%. Comparing base (936bb62) to head (52c74a8).
⚠️ Report is 59 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/web/static/js/src/dt_plugins/natsort.js 70.58% 0 Missing and 5 partials ⚠️
...on/nav/web/static/js/src/info/global_dt_filters.js 33.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3730      +/-   ##
==========================================
+ Coverage   63.23%   63.27%   +0.03%     
==========================================
  Files         617      618       +1     
  Lines       45662    45727      +65     
  Branches       43       43              
==========================================
+ Hits        28874    28933      +59     
- Misses      16778    16784       +6     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Simrayz Simrayz changed the title Chore/upgrade jquery to v4 Upgrade jquery to v4 Jan 27, 2026
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Jan 27, 2026

A few annoying bugs:

  • SonarQube is complaining about a regex in the jquery-migrate dependency 😄
  • The Javascript test suite is failing due to an undefined bug in the jquery-migrate dependency 🙃

This dependency is necessary for jquery-tablesorter, jquery-sparkline and datatables to work with jQuery v4, but I am working on replacing them. Hopefully we can remove this dependency soon, but datatables might take a while to replace.

@Simrayz Simrayz force-pushed the chore/upgrade-jquery-to-v4 branch 2 times, most recently from a90fa68 to c2191ba Compare January 30, 2026 14:21
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Feb 2, 2026

The related PRs upgrade and replace the dependencies that require jquery-migrate to work: #3740 (jquery-tablesort), #3744 (jquery-sparkline), #3751 (datatables v1 -> v2)

@hmpf hmpf added the jquery label Feb 3, 2026
@Simrayz Simrayz marked this pull request as ready for review February 3, 2026 12:24
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Feb 3, 2026

This PR can be reviewed separately, but should be merged after all dependencies are approved, as I want to remove the jquery-migrate library

@hmpf
Copy link
Copy Markdown
Contributor

hmpf commented Feb 3, 2026

Manual test:

  • seeddb, seems ok
  • machine tracker seems ok
  • cannot save in portadmin but that might be because testing with a copy of db with no access to actual devices
  • room rack view -> device info -> pick box: sparklines ok
  • ip device sparklines: same page as above?

Copy link
Copy Markdown
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunkwill42, could you check saving in portadmin?

@Simrayz Simrayz mentioned this pull request Feb 4, 2026
10 tasks
@Simrayz Simrayz force-pushed the chore/upgrade-jquery-to-v4 branch from 44ed5d8 to b9ceec4 Compare February 5, 2026 11:19
@Simrayz Simrayz mentioned this pull request Feb 9, 2026
10 tasks
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lunkwill42, could you check saving in portadmin?

When I get time to set up my environment for it properly, which very likely won't happen until Wednesday this week.

Also, has anyway looked at the SonarQube errors?

@Simrayz Simrayz force-pushed the chore/upgrade-jquery-to-v4 branch 2 times, most recently from f14fb08 to 1e94624 Compare February 11, 2026 08:37
@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Feb 11, 2026

This branch has merged in changes from four different dependency upgrade/replacement PRs. These changes have already been tested and approved. To make it easier to review/pass this mega/meta PR I've created this commit mapping.

jquery-upgrade-commit-map

@lunkwill42
Copy link
Copy Markdown
Member

Some of the SonarCloud complaints here seem to be about the vendored-in plugin code. We should maybe find a way to exclude those from analysis in .sonarcloud.properties, as we don't want to change vendored-in code that we don't plan to maintain.

@lunkwill42
Copy link
Copy Markdown
Member

lunkwill42 commented Feb 12, 2026

I pushed a commit to ensure SonarQube ignores vendored-in code, but it still flags some issues with the code that should be reviewed, fixed or dismissed.

Also, not sure how the split-brain JS works, but base.html still loads jQuery 3.7.1 globally. Does that not affect anything?

@lunkwill42
Copy link
Copy Markdown
Member

@lunkwill42, could you check saving in portadmin?

Tested - it appears to work just fine 👍

@lunkwill42
Copy link
Copy Markdown
Member

Something is slightly off with job duration sparklines in ipdevinfo, though: Average duration is now displayed below the sparkline, instead of to the right, causing increased vertical space usage per row.

Original:

image

New version:

image

@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Feb 12, 2026

@lunkwill42 I have pushed three commits which address your feedback (and one regression with spot dots on the sparklines):

  • The reference to jQuery 3.7.1 was changed to v4, and the file was removed
  • Sonarqube issues have been addressed (while function should be defined outside scope issues were marked as false positives)
  • Added spot dots (min, max, last data) which were not ported when creating the pure d3.js implementation

@Simrayz Simrayz requested a review from lunkwill42 February 12, 2026 09:45
Simrayz and others added 22 commits February 12, 2026 15:22
Patch the single jQuery 4 incompatibility ($.camelCase removal) with a
native String.replace equivalent. No other library depends on
jquery-migrate, so it can be fully removed.
Select2 4.1.0-rc.0 replaced aria-attribute selectors with BEM-style
class selectors for option states (selected, highlighted, disabled).
We will never fix linting issues in vendored-in code, so we should
make sure SonarCloud ignores it.
@Simrayz Simrayz force-pushed the chore/upgrade-jquery-to-v4 branch from 61c45cd to 52c74a8 Compare February 12, 2026 14:22
@sonarqubecloud
Copy link
Copy Markdown

@Simrayz
Copy link
Copy Markdown
Contributor Author

Simrayz commented Feb 12, 2026

@lunkwill42 I removed jQuery as a dependency in the d3_sparkline plugin, which eliminates the "implicit jQuery" warning and decouples us from jQuery in this file.

Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Let's fly with this!

@lunkwill42 lunkwill42 merged commit ecaca47 into master Feb 13, 2026
19 checks passed
@lunkwill42 lunkwill42 deleted the chore/upgrade-jquery-to-v4 branch February 13, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file javascript jquery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants