Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/js/infragistics.loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2380,7 +2380,7 @@ $.extend($.ig.loaderClass, {
this._loadBatches.push(loadBatch);

for (i = 0; i < res.length; i++) {
(new $.ig._loadWorkItem(this)).loadWidgetResources($.trim(res[ i ]), loadBatch.callback);
(new $.ig._loadWorkItem(this)).loadWidgetResources(res[ i ].trim(), loadBatch.callback);
}
}
return this;
Expand Down Expand Up @@ -2524,7 +2524,7 @@ $.extend($.ig.loaderClass, {
locales = this.settings.locale.split(",");
localeScr = localeScripts.pop();
for ( k = 0; k < locales.length; k++) {
scriptData.unshift(localeScr.replace("$locale$", $.trim(locales[ k ])));
scriptData.unshift(localeScr.replace("$locale$", locales[ k ].trim()));
}
}
}
Expand All @@ -2536,7 +2536,7 @@ $.extend($.ig.loaderClass, {
while (regionalScripts.length > 0) {
regionalScr = regionalScripts.pop();
for ( k = 0; k < regionals.length; k++) {
scriptData.unshift(regionalScr.replace("$regional$", $.trim(regionals[ k ])));
scriptData.unshift(regionalScr.replace("$regional$", regionals[ k ].trim()));
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/js/modules/infragistics.datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2102,7 +2102,7 @@
return "invalid";
}
if ($.ig.util.getType(ds) === "string") { //string or object
ds = $.trim(ds);
ds = $.ig.util.trim(ds);
if (ds.startsWith("/")) {
return "remoteUrl";
}
Expand Down Expand Up @@ -4009,7 +4009,7 @@
// M.H. 9 Oct 2013 Fix for bug #139006: dataSourceType should be set explicitly when invoke dataBind with remote operations
ds = this.dataSource();
if ($.ig.util.getType(ds) === "string") { //string or object
ds = $.trim(ds);
ds = $.ig.util.trim(ds);
/* N.A. 02/10/2014 Bug #162293 Add support for https requests. */
if (ds.startsWith("/") || ds.startsWith("http://") || ds.startsWith("https://")) {
this._runtimeType = "remoteUrl";
Expand Down Expand Up @@ -4497,7 +4497,7 @@
}
}
/* try to analyze and detect automatically */
data = $.ig.util.getType(data) === "string" ? $.trim(data) : data;
data = $.ig.util.getType(data) === "string" ? $.ig.util.trim(data) : data;
if ((data && $.ig.util.getType(data) === "string" && (data.startsWith("<?xml") ||
data.startsWith("<"))) || t === "xml") {
/* assume XML */
Expand Down Expand Up @@ -5771,7 +5771,7 @@

for (i = 0; i < tmp.length; i++) {
fields[ i ] = {};
tmp2 = $.trim(tmp[ i ]).split(" ");
tmp2 = $.ig.util.trim(tmp[ i ]).split(" ");
fields[ i ].fieldName = tmp2[ 0 ];
fields[ i ].dir = tmp2[ 1 ];
}
Expand Down Expand Up @@ -6209,17 +6209,17 @@
},
_parseFilterExprString: function (expr) {
//A.T. 18 Jan 2011 - fix for bug #62418
var exprs = $.trim(expr).split(/(?=AND+)|(?=OR+)/i), i, j, fields = [], tmp, tmp2, isInvalid = true;
var exprs = $.ig.util.trim(expr).split(/(?=AND+)|(?=OR+)/i), i, j, fields = [], tmp, tmp2, isInvalid = true;
for (i = 0; i < exprs.length; i++) {
fields[ i ] = {};
/* A.T. 18 Jan 2011 - Fix for bug #62415 - equality sign (=) is not parsed when in a filtering expression string */
/* A.T. 19 Jan 2011 - removing (IN) operator. (bug #62365) */
tmp = $.trim(exprs[ i ]).split(/(?= \=+)|(?=<>+)|(?=>+)|(?=<+)|(?=LIKE+)|(?=NOT\WLIKE)+|(?=>\=+)|(?=<\=+)/);
if ($.trim(exprs[ i ]).toLowerCase().startsWith("and")) {
tmp = $.ig.util.trim(exprs[ i ]).split(/(?= \=+)|(?=<>+)|(?=>+)|(?=<+)|(?=LIKE+)|(?=NOT\WLIKE)+|(?=>\=+)|(?=<\=+)/);
if ($.ig.util.trim(exprs[ i ]).toLowerCase().startsWith("and")) {
fields[ i ].logic = "AND";
/* strip AND
tmp[0] = tmp[0].substring(tmp.indexOf(3)); */
} else if ($.trim(exprs[ i ]).toLowerCase().startsWith("or")) {
} else if ($.ig.util.trim(exprs[ i ]).toLowerCase().startsWith("or")) {
fields[ i ].logic = "OR";
/* strip OR
tmp[0] = tmp[0].substring(tmp.indexOf(2)); */
Expand All @@ -6229,11 +6229,11 @@
fields[ i - 1 ].logic = fields[ i ].logic;
}
if (tmp[ 0 ].toLowerCase().startsWith("and") || tmp[ 0 ].toLowerCase().startsWith("or")) {
fields[ i ].fieldName = $.trim(tmp[ 0 ].split(" ")[ 1 ]);
fields[ i ].fieldName = $.ig.util.trim(tmp[ 0 ].split(" ")[ 1 ]);
} else {
fields[ i ].fieldName = $.trim(tmp[ 0 ]);
fields[ i ].fieldName = $.ig.util.trim(tmp[ 0 ]);
}
tmp2 = $.trim(tmp[ 1 ]).split(" ");
tmp2 = $.ig.util.trim(tmp[ 1 ]).split(" ");
/* fix ambiguous matching between <, >, and <> */
if (exprs[ i ].indexOf("<>") !== -1) {
tmp2[ 0 ] = "<>";
Expand All @@ -6249,7 +6249,7 @@
tmp2 = [ tmp2[ 0 ], tmp2[ 1 ] ];
}
if (tmp[ 1 ].startsWith("NOT")) {
fields[ i ].expr = $.trim(tmp[ 2 ].replace("LIKE", ""));
fields[ i ].expr = $.ig.util.trim(tmp[ 2 ].replace("LIKE", ""));
} else {
fields[ i ].expr = tmp2[ 1 ];
}
Expand Down Expand Up @@ -6357,7 +6357,7 @@
return true;
}

tmpExpr = $.trim(expr);
tmpExpr = $.ig.util.trim(expr);
/*if (t === null || t === undefined) {
t = $.ig.util.getType(expr);
} */
Expand Down Expand Up @@ -8282,7 +8282,7 @@
text = "";
for (i = 0; i < li[ 0 ].childNodes.length; i++) {
if (li[ 0 ].childNodes[ i ].nodeType === 3 && li[ 0 ].childNodes[ i ].data) {
text += $.trim(li[ 0 ].childNodes[ i ].data);
text += $.ig.util.trim(li[ 0 ].childNodes[ i ].data);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/modules/infragistics.ui.htmleditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1955,12 +1955,12 @@

// K.D. October 3rd, 2012 Bug #123366 Encoding the content before setting the value
// D.A. November 4th, 2013 Bug #155847 Viewsource cannot be switched when there are leading whitespaces
this.sourceWindow.val($.trim(workSpaceBody.html()));
this.sourceWindow.val($.ig.util.trim(workSpaceBody.html()));
workspace.hide();
this.sourceWindow.show();
} else {
workSpaceBody.attr("contentEditable", true);
workSpaceBody.html($.trim(this.sourceWindow.val()));
workSpaceBody.html($.ig.util.trim(this.sourceWindow.val()));
Comment thread
ChronosSF marked this conversation as resolved.
Dismissed
workspace.show();
this.sourceWindow.hide();

Expand Down
6 changes: 6 additions & 0 deletions src/js/modules/infragistics.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4437,6 +4437,12 @@
return str.replace(new RegExp($.ig.util.escapeRegExp(oldValue), "g"), newValue);
};

// Replaces $.trim, which jQuery 4 removed: null and undefined give "",
// other values are converted to a string and trimmed on both ends
$.ig.util.trim = function (value) {
return value == null ? "" : String(value).trim();
};

// Implements the .NET String.Format functionality
$.ig.util.stringFormat = function (format) {
return $.ig.util.stringFormat1(format, Array.prototype.slice.call(arguments, 1));
Expand Down
34 changes: 34 additions & 0 deletions tests/unit/dataSource/filtering/filtering-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,3 +1440,37 @@ QUnit.module("igDataSource filtering", {
fd = ds.filteredData();
assert.ok(fd.length === 0, "The items shoould not be filtered");
});

QUnit.module("igDataSource filtering without $.trim (jQuery 4)", {
trim: null,
beforeEach: function () {
// jQuery 4 removed $.trim: https://github.com/IgniteUI/ignite-ui/issues/2302
this.trim = $.trim;
delete $.trim;
},
afterEach: function () {
$.trim = this.trim;
}
});

QUnit.test("Local filtering with field expressions", function (assert) {
assert.expect(1);
var ds = new $.ig.DataSource({
dataSource: [{ ID: 1 }, { ID: 2 }, { ID: 3 }],
schema: { fields: [{ name: "ID", type: "number" }] }
});
ds.dataBind();
ds.filter([{ fieldName: "ID", expr: 2, cond: "greaterThan" }], "AND", true);
assert.deepEqual(ds.dataView(), [{ ID: 3 }], "Only the record with ID 3 should be left.");
});

QUnit.test("Local filtering with an expression string", function (assert) {
assert.expect(1);
var ds = new $.ig.DataSource({
dataSource: [{ ID: 1 }, { ID: 2 }, { ID: 3 }],
schema: { fields: [{ name: "ID", type: "number" }] }
});
ds.dataBind();
ds.filter(" ID > 1 AND ID < 3 ", true);
assert.deepEqual(ds.dataView(), [{ ID: 2 }], "Only the record with ID 2 should be left.");
});
52 changes: 52 additions & 0 deletions tests/unit/dataSource/remote/remote-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1790,3 +1790,33 @@ QUnit.test('[ID74] igHtmlEditor igToolbarHelper unit tests - Add image to editor
});
});

QUnit.module("igHTMLEditor without $.trim (jQuery 4)", {
trim: null,
beforeEach: function () {
// jQuery 4 removed $.trim: https://github.com/IgniteUI/ignite-ui/issues/2302
this.trim = $.trim;
delete $.trim;
},
afterEach: function () {
$.trim = this.trim;
}
});

QUnit.test("Switch to the source view and back", function (assert) {
assert.expect(4);
var htmlEditor = $.ig.TestUtil.appendToFixture('<div></div>', { id: "trimHtmlEditor" }).igHtmlEditor({}),
viewSourceBtn = htmlEditor.find(".ui-igbutton-viewsource"),
designView = $("#trimHtmlEditor_editor"),
sourceView = $("#trimHtmlEditor_source");

htmlEditor.igHtmlEditor("setContent", "<p>test</p>", "html");
viewSourceBtn.click();
assert.notOk(designView.is(":visible"), "The source view should be shown.");
assert.equal(sourceView.val(), "<p>test</p>", "The source view should contain the content.");

sourceView.val(" <p>changed</p> ");
viewSourceBtn.click();
assert.ok(designView.is(":visible"), "The design view should be shown.");
assert.equal(htmlEditor.igHtmlEditor("getContent", "html"), "<p>changed</p>", "The edited source should be applied without the surrounding whitespace.");
});

45 changes: 45 additions & 0 deletions tests/unit/loader/loader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,49 @@ QUnit.test("test 4: Test load resources with multiple regionals", function (asse
done();
}
});
});

QUnit.module("igLoader without $.trim (jQuery 4)", {
jsPath: "base/mock/src/js/",
cssPath: "base/mock/src/css/",
trim: null,
beforeEach: function () {
// jQuery 4 removed $.trim: https://github.com/IgniteUI/ignite-ui/issues/2302
this.trim = $.trim;
delete $.trim;
},
afterEach: function () {
$.trim = this.trim;
$("head > script[src*='" + this.jsPath + "'], head > link[href*='" + this.cssPath + "']").remove();
}
});

QUnit.test("Load resources, locales and regionals from lists with spaces", function (assert) {
assert.expect(5);
var done = assert.async(),
expectedScripts = [
"infragistics.templating.js",
"infragistics.templating-fr.js",
"infragistics.ui.editors.js",
"infragistics.ui.editors-fr.js",
"infragistics.ui.regional-fr.js"
];

$.ig.loader({
scriptPath: this.jsPath,
cssPath: this.cssPath,
resources: "igTemplating, igEditors",
locale: "en, fr",
regional: "en, fr",
ready: () => {
var loadedScripts = $("head > script[src*='" + this.jsPath + "']").map(function () {
return this.src.split("/").pop();
}).get();

expectedScripts.forEach(function (script) {
assert.ok(loadedScripts.indexOf(script) !== -1, "The loaded resources should contain: " + script);
});
done();
}
});
});
23 changes: 23 additions & 0 deletions tests/unit/util/util-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,27 @@ QUnit.test('[ID21] Test String.concat', function (assert) {
var arr = ["abc", "123"];
assert.equal(String.concat(arr[0], arr[1]), "abc123", "Default w/ Separate arguments");
assert.equal(String.concat(arr), "abc123", "Default w/ single argument");
});

QUnit.test('[ID22] Test $.ig.util.trim', function (assert) {
assert.expect(14);

var trim = $.trim,
values = [null, undefined, 0, 42, " ABC ", "\u00A0\uFEFF\t\r\n ABC \u00A0\uFEFF\t\r\n", "A B"],
expected = ["", "", "0", "42", "ABC", "ABC", "A B"],
i;

for (i = 0; i < values.length; i++) {
assert.strictEqual($.ig.util.trim(values[i]), trim(values[i]), "Same result as $.trim for " + JSON.stringify(values[i]));
}

// jQuery 4 removed $.trim: https://github.com/IgniteUI/ignite-ui/issues/2302
delete $.trim;
try {
for (i = 0; i < values.length; i++) {
assert.strictEqual($.ig.util.trim(values[i]), expected[i], "Trimmed without $.trim: " + JSON.stringify(values[i]));
}
} finally {
$.trim = trim;
}
});