Skip to content

fix(*): replace $.trim, which jQuery 4 removed #2302 - #2303

Merged
ChronosSF merged 2 commits into
masterfrom
sstoychev/replace-jquery-trim
Nov 19, 2026
Merged

ChronosSF merged 2 commits into
masterfrom
sstoychev/replace-jquery-trim

Conversation

@ChronosSF

Copy link
Copy Markdown
Member

Closes #2302

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

  • src/js/modules/infragistics.util.js: new $.ig.util.trim(value), which behaves like $.trim on every jQuery version: null and undefined give "", other values are converted with String(value) and trimmed with String.prototype.trim.
  • src/js/modules/infragistics.datasource.js: the 14 $.trim calls now use $.ig.util.trim. The module already depends on ./infragistics.util.
  • src/js/modules/infragistics.ui.htmleditor.js: the 2 $.trim calls in _viewSource now use $.ig.util.trim. infragistics.util.js is loaded through ./infragistics.ui.widget, and the editor already uses $.ig.util.
  • src/js/infragistics.loader.js: the loader is a standalone script that runs before it loads infragistics.util.js and never uses $.ig.util, so it does not use the helper. Its 3 calls trim elements of arrays returned by split(","), which are always strings, so they now call .trim() on them directly. For a string this gives the same result as $.trim.
  • Tests that remove $.trim for the duration of the test (restored in afterEach/finally) to simulate jQuery 4 on the jQuery 3.7.1 the test runner uses:
    • tests/unit/util/util-test.js: $.ig.util.trim gives the same result as $.trim for null, undefined, 0, 42, a string with surrounding spaces, a string with surrounding \u00A0\uFEFF\t\r\n and an already-trimmed string, and the expected results without $.trim.
    • tests/unit/dataSource/remote/remote-test.js: a $.ig.DataSource bound to a URL string (default type and type: "json") recognizes it as remoteUrl and binds a mocked text response that has surrounding whitespace (mockjax, no network).
    • tests/unit/dataSource/filtering/filtering-test.js: the local filter from the issue leaves [{ ID: 3 }]; a filter expression string (" ID > 1 AND ID < 3 ") leaves [{ ID: 2 }].
    • tests/unit/htmleditor/basicfunctionalities/rendering/htmleditor-test.js: switching to the source view and back trims the content.
    • tests/unit/loader/loader-test.js: loading "igTemplating, igEditors" with locale and regional "en, fr" loads the expected scripts.

Verified

  • npx grunt hint: 32 files lint free.
  • New tests without the source change (git stash push -- src, then npx karma start --single-run --testPath "unit/{util,dataSource/filtering,dataSource/remote,loader,htmleditor/basicfunctionalities/rendering}"): 7 FAILED, 175 SUCCESS. The 7 failures are exactly the new tests, each with TypeError: $.trim is not a function (or $.ig.util.trim is not a function for the helper test).
  • The same command with the change: 182 SUCCESS.
  • npm run cover (JSHint and the full Karma suite) with the change: lint free, 4 FAILED, 1498 SUCCESS. All new tests pass. The failures are in tests this change does not touch:
    • igVideoPlayer tests 48 and 50 also fail on master (npm run cover on 026d3ff: 2 FAILED, 1493 SUCCESS, the same two tests).
    • igUpload [ID4] igUpload SINGLE MODE resource test finish file fails the same way on master when the scroll and upload tests are run on their own (--testPath "unit/{scroll,upload}", twice on each branch).
    • igScroll "clicking on arrow up, moving the mouse out..." failed once and passed in the other full run and in two runs of unit/{scroll,upload}. It is timing-dependent.
  • With real jQuery 4.1.0 (a page loading jquery.js 4.1.0, infragistics.util.js, infragistics.util.jquery.js, infragistics.datasource-en.js and infragistics.datasource.js, in headless Chrome):
    • On master, the local filter from the issue, new $.ig.DataSource({ dataSource: "/api/products", responseDataKey: "d.results" }).dataBind() and a data source bound to a local JSON file all throw TypeError: $.trim is not a function.
    • With this change, the filter leaves [{"ID":3}], the /api/products data source binds without an exception, and the JSON file data source reports remoteUrl and binds all 3 records.

Not verified

  • The Karma suite itself still runs on jQuery 3.7.1, so the jQuery 4 behaviour in the unit tests is simulated by removing $.trim. I checked only the data source against real jQuery 4.1.0. The HTML editor and the loader were not run on jQuery 4, because the test setup uses jQuery UI 1.13.0, which is not built for jQuery 4.
  • JSCS: the repository has no .jscsrc, no JSCS dependency and no JSCS task (npx grunt verify runs only JSHint), so JSCS was not run. The changed source lines keep the existing style, such as res[ i ].trim().

🤖 Generated with Claude Code

jQuery 4 removed $.trim, so igDataSource, igHtmlEditor and the loader
threw "$.trim is not a function", for example when binding the data
source to a URL or filtering it locally.

Add $.ig.util.trim, which behaves like $.trim on every jQuery version:
null and undefined give "", other values are converted to a string and
trimmed. Use it in the data source and the HTML editor. The loader runs
before infragistics.util.js is loaded and only trims the strings it
gets from split(","), so it calls String.prototype.trim directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coveralls

coveralls commented Nov 19, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.604% (+0.002%) from 84.602% — sstoychev/replace-jquery-trim into master

@ChronosSF
ChronosSF merged commit 2632b4c into master Nov 19, 2026
5 checks passed
@ChronosSF
ChronosSF deleted the sstoychev/replace-jquery-trim branch November 19, 2026 15:59
@ChronosSF ChronosSF mentioned this pull request Nov 25, 2026
3 of 11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jQuery 4: $.trim is not a function in igDataSource, igHtmlEditor and the loader

3 participants