Repository navigation
fix(*): replace $.trim, which jQuery 4 removed #2302 - #2303
Merged
Merged
Conversation
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>
11 tasks
3 of 11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2302
Additional information (check all that apply):
Checklist:
README.MDWhat changed
src/js/modules/infragistics.util.js: new$.ig.util.trim(value), which behaves like$.trimon every jQuery version:nullandundefinedgive"", other values are converted withString(value)and trimmed withString.prototype.trim.src/js/modules/infragistics.datasource.js: the 14$.trimcalls now use$.ig.util.trim. The module already depends on./infragistics.util.src/js/modules/infragistics.ui.htmleditor.js: the 2$.trimcalls in_viewSourcenow use$.ig.util.trim.infragistics.util.jsis 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 loadsinfragistics.util.jsand never uses$.ig.util, so it does not use the helper. Its 3 calls trim elements of arrays returned bysplit(","), which are always strings, so they now call.trim()on them directly. For a string this gives the same result as$.trim.$.trimfor the duration of the test (restored inafterEach/finally) to simulate jQuery 4 on the jQuery 3.7.1 the test runner uses:tests/unit/util/util-test.js:$.ig.util.trimgives the same result as$.trimfornull,undefined,0,42, a string with surrounding spaces, a string with surrounding\u00A0\uFEFF\t\r\nand an already-trimmed string, and the expected results without$.trim.tests/unit/dataSource/remote/remote-test.js: a$.ig.DataSourcebound to a URL string (defaulttypeandtype: "json") recognizes it asremoteUrland 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.git stash push -- src, thennpx 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 withTypeError: $.trim is not a function(or$.ig.util.trim is not a functionfor the helper test).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:master(npm run coveron 026d3ff:2 FAILED, 1493 SUCCESS, the same two tests).[ID4] igUpload SINGLE MODE resource test finish filefails the same way onmasterwhen the scroll and upload tests are run on their own (--testPath "unit/{scroll,upload}", twice on each branch).unit/{scroll,upload}. It is timing-dependent.jquery.js4.1.0,infragistics.util.js,infragistics.util.jquery.js,infragistics.datasource-en.jsandinfragistics.datasource.js, in headless Chrome):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 throwTypeError: $.trim is not a function.[{"ID":3}], the/api/productsdata source binds without an exception, and the JSON file data source reportsremoteUrland binds all 3 records.Not verified
$.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..jscsrc, no JSCS dependency and no JSCS task (npx grunt verifyruns only JSHint), so JSCS was not run. The changed source lines keep the existing style, such asres[ i ].trim().🤖 Generated with Claude Code