Skip to content

fix(*): support jQuery 4 #2304 - #2310

Open
ChronosSF wants to merge 5 commits into
masterfrom
sstoychev/jquery4-support
Open

ChronosSF wants to merge 5 commits into
masterfrom
sstoychev/jquery4-support

Conversation

@ChronosSF

Copy link
Copy Markdown
Member

Closes #2304
Part of #2291

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code
  • This PR includes API docs for newly added methods/properties
  • This PR includes general feature table updates in the root README.MD
  • This PR contains breaking changes
  • This PR includes behavioral changes and the feature specification has been updated with them

What changed

Everything #2304 lists that is in this repository, plus four problems that only showed up when the Karma suite ran on jQuery 4.1.0. Five commits, easiest to review one at a time.

1. fix(*): support jQuery 4 (245c1ae)

From the issue:

  • igHtmlEditor: _createToolbars called $.camelCase, so the editor threw while it was created. It now camel-cases the option name with the same regular expression.
  • $.ig.util.ajax: $.support.cors is gone, so every request went out with crossDomain: false; jQuery then adds X-Requested-With, which makes a cross-origin request need a preflight. It now defaults to true, the value $.support.cors had in every browser jQuery 4 supports.

Not in the issue, found by running the suite on jQuery 4.1.0:

  • igToolbar _getWidgetType called hasOwnProperty on an element's .data() object. jQuery 4 creates those objects without a prototype, so it threw whenever igHtmlEditor disabled a toolbar item, and every igHtmlEditor test failed. It now calls Object.prototype.hasOwnProperty.
  • jQuery 4's .attr() returns the value of a boolean attribute instead of its name, and the value is "" when the attribute is written without one. igCombo ignored <select multiple>, the editors ignored disabled and readonly in the markup, and igCheckboxEditor ignored checked. They now test for the attribute with .is("[name]"), which gives the result jQuery 3's .attr() gave, on every version.

Tests: $.type is replaced with $.ig.util.getType and $.trim with String.prototype.trim; the vendored jquery.simulate no longer calls $.camelCase; [ID22] runs without $.trim; 17 assertions that compared .attr("disabled") or .attr("readonly") with "disabled"/"readonly" now test for the attribute. New tests: [ID23] for $.ig.util.ajax without $.support.cors, and an editors test for boolean attributes written without a value.

2. fix(zoombar): render the scroll buttons on jQuery UI 1.14 (eed12c1)

jQuery UI 1.14, which jQuery 4 needs, sets $.uiBackCompat to false by default, so the button widget ignores the icons and text options igZoombar passed. The scroll buttons rendered without their icon element, and clicking them did not move the zoom window, because the click handler checks that element's class. This also affects jQuery 3 with jQuery UI 1.14. igZoombar now passes icon and showLabel as well, and keeps the old options for jQuery UI 1.11 and earlier. No other module in src/js uses an option or API that jQuery UI 1.14 moved behind $.uiBackCompat.

3. fix(build): drop jquery-ui/ui/core from the bundle AMD headers (12716bb)

jQuery UI 1.14 removed ui/core.js, so loading infragistics.core-lite.js or infragistics.lob-lite.js through AMD or a bundler failed with Can't resolve 'jquery-ui/ui/core'. ui/core only loaded other modules, and the headers already list the ones src/js uses. #2291 reports this for @infragistics/ignite-ui-full, which is built separately and needs the same change there, so this PR is part of #2291.

4. chore(*): allow jQuery 4 and update the test dependencies for it (18371d8)

  • package.json: jquery is ^3.7.1 || ^4.0.0. The lockfile still installs 3.7.1, so the default setup and the existing CI job do not change. bower.json: ^3.1.1 || ^4.0.0, was pinned to 3.1.1. The published build/packages/package.json already has jquery: >=1.9.1 as a peer dependency and is unchanged.
  • jquery-mockjax ^2.7.0: 2.6.0 called $.isFunction, $.isArray and $.parseJSON.
  • jquery-ui ^1.14.2, the first release tested with jQuery 4. Karma loads it from node_modules/jquery-ui/dist instead of 1.13.0 from code.jquery.com, so the suite now runs on jQuery UI 1.14.2.
  • jquery.tmpl (beta1, from ajax.microsoft.com) calls jQuery.isArray and jQuery.trim. The data source filtering, paging and sorting tests only used it to render their data. They now use $.ig.tmpl, skipping empty records as jquery.tmpl did, and Karma no longer loads jquery.tmpl. bower.json drops jquery-tmpl.

5. ci: run the tests on jQuery 4.1 too (ab78ccc)

A second job installs jquery@4.1 with npm install --no-save and runs the same Karma suite. It skips the igZoombar tests with --testPath 'unit/!(zoombar)/**', because the charts scripts they load from the CDN call $.type. That fix belongs to the charts package and is being done there; once it ships, drop the --testPath argument.

Verified

  • npx grunt hint: 32 files lint free.
  • Full Karma suite on jQuery 3.7.1 (the lockfile): 1504 tests, 1 FAILED, igVideoPlayer test 50, which also fails on master (see fix(*): replace $.trim, which jQuery 4 removed #2302 #2303) and passed in other runs of this branch.
  • Full suite with jQuery 4.1.0 in place of node_modules/jquery:
    • With only the fixes the issue lists: 110 failures (71 igHtmlEditor, 21 igZoombar, 9 Knockout, 6 igCombo, 2 runtime locale, 1 igVideoPlayer).
    • With this branch: 23 failures. 21 are the igZoombar tests ($.type is not a function in the CDN charts scripts); with $.type put back in a local experiment, all 21 pass on jQuery 4.1.0. The other two depend on order or timing: igUpload [ID4] igUpload SINGLE MODE resource test finish file also fails when the upload tests run alone with master's jQuery UI 1.13.0 and mockjax 2.6.0, and igDataSource "Test binding to remote - error", which waits 500 ms for a real 404, passed in 2 of 3 runs on its own.
  • The new CI job's commands, locally: npm install --no-save jquery@4.1, then npx karma start --single-run --testPath 'unit/!(zoombar)/**': Executed 1483 of 1483 SUCCESS.
  • The new tests fail without their fix: [ID23] with the old $.support.cors line (jQuery 3.7.1), and the boolean attribute test with the old editors code on jQuery 4.1.0 (the disabled option stays false). igCombo [ID13] Multiple selection on <select multiple> element failed on jQuery 4.1.0 before the combo change.
  • igZoombar test 2.1 failed in 3 of 3 runs on jQuery UI 1.14.2 before commit 2, and all igZoombar tests pass on jQuery UI 1.14.2 and 1.13.0 after it.

Not verified

  • Loading infragistics.core-lite.js and infragistics.lob-lite.js through an AMD loader or a bundler. I checked the headers by searching src/js for the modules ui/core loaded, but did not build the lite bundles and load them.
  • igZoombar with jQuery UI 1.11 or earlier, which uses the icons and text options kept for it.
  • The demos. They load jQuery UI 1.12.1 from code.jquery.com next to node_modules/jquery; with the lockfile's 3.7.1 nothing changes for them, but they would not work on jQuery 4. Not changed here.
  • The issue's charts item (infragistics.dvcommonwidget.js) is outside this repository; see commit 5.

🤖 Generated with Claude Code

ChronosSF and others added 5 commits November 25, 2026 13:51
jQuery 4 removed $.camelCase and $.support.cors, creates .data() objects
without a prototype, and returns the value of a boolean attribute from
.attr() instead of its name. That broke several widgets:

- igHtmlEditor threw "$.camelCase is not a function" while creating its
  toolbars, so it never rendered. Camel-case the option name with a
  regular expression instead.
- igToolbar called hasOwnProperty on an element's .data() object, which
  threw whenever the HTML editor disabled a toolbar item. Call
  Object.prototype.hasOwnProperty instead.
- $.ig.util.ajax sent every request with crossDomain: false, because
  $.support.cors was undefined. jQuery then added X-Requested-With, so
  cross-origin requests needed a CORS preflight. Default to true, the
  value $.support.cors had in every browser jQuery 4 supports.
- .attr() returns "" for a boolean attribute written without a value, so
  igCombo ignored <select multiple>, the editors ignored disabled and
  readonly in the markup, and igCheckboxEditor ignored checked. Check for
  the attribute with .is("[name]"), which works the same on jQuery 3 and 4.

Update the tests to run on jQuery 4: use $.ig.util.getType instead of
$.type and String.prototype.trim instead of $.trim, check boolean
attributes for presence instead of comparing their values, patch the
vendored jquery.simulate, which used $.camelCase, and let [ID22] run
without $.trim. Add tests for $.ig.util.ajax without $.support.cors and
for boolean attributes without a value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jQuery UI 1.14 sets $.uiBackCompat to false by default, so the button
widget ignores the icons and text options igZoombar passed. The scroll
buttons rendered without their icon element, and clicking them did not
move the zoom window, because the click handler checks that element's
class to tell left from right. jQuery 4 needs jQuery UI 1.14.2 or later,
but this also affects jQuery 3 with jQuery UI 1.14.

Pass icon and showLabel, the options jQuery UI 1.12 and later use, and
keep icons and text for jQuery UI 1.11 and earlier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jQuery UI 1.14 removed ui/core.js, so loading infragistics.core-lite.js
or infragistics.lob-lite.js through AMD or a bundler failed with "Can't
resolve 'jquery-ui/ui/core'". jQuery 4 needs jQuery UI 1.14.2 or later,
so this also kept those users off jQuery 4.

The headers already list the jQuery UI modules the bundles use. ui/core
only added modules nothing in src/js uses (disable-selection, form, ie,
labels, plugin, safe-active-element, safe-blur, scroll-parent,
unique-id), so removing it changes nothing on jQuery UI 1.12 and 1.13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- package.json and bower.json now allow jQuery 4. The lockfile still
  installs jQuery 3.7.1.
- jquery-mockjax 2.6.0 called $.isFunction, $.isArray and $.parseJSON.
  2.7.0 supports jQuery 4.
- Karma loaded jQuery UI 1.13.0 from code.jquery.com instead of the
  jquery-ui package, which ships a bundle in dist/. Load it from
  node_modules and require 1.14.2, the first release tested with
  jQuery 4.
- jquery.tmpl (beta1, from ajax.microsoft.com) calls jQuery.isArray and
  jQuery.trim. The data source filtering, paging and sorting tests only
  used it to render their data, so render it with $.ig.tmpl, skipping
  empty records as jquery.tmpl did, and stop loading jquery.tmpl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build job only tests the jQuery version in package-lock.json, which
is 3.7.1. Add a job that installs jQuery 4.1 without saving it and runs
the same Karma suite, so changes that break jQuery 4 show up in pull
requests.

The job skips the igZoombar tests for now: the charts scripts they load
from the CDN call $.type, which jQuery 4 removed. Drop the --testPath
argument once the charts package no longer calls it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChronosSF ChronosSF added the jQuery 4 Compatibility with jQuery 4 label Nov 25, 2026
Comment on lines +43 to +62
name: Test on jQuery 4.1

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- name: Use Node.js 20.x
uses: actions/setup-node@v7
with:
node-version: 20.x
cache: 'npm'
- run: npm ci
- name: Install jQuery 4.1
run: |
npm install --no-save jquery@4.1
npm ls jquery
# Skips the igZoombar tests: the charts scripts they load from the CDN
# call $.type, which jQuery 4 removed. Remove the --testPath argument
# once the charts package no longer calls it.
- run: npx karma start --single-run --testPath 'unit/!(zoombar)/**'
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 84.643% — sstoychev/jquery4-support into master. No base build found for master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jQuery 4 Compatibility with jQuery 4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support jQuery 4: replace APIs jQuery 4 removed

3 participants