diff --git a/src/js/modules/infragistics.util.js b/src/js/modules/infragistics.util.js index 9107c5cfa..dc51a08e1 100644 --- a/src/js/modules/infragistics.util.js +++ b/src/js/modules/infragistics.util.js @@ -3836,36 +3836,32 @@ return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g, "").replace(/\s+/g, " "); }; - String.prototype.trimStart = function () { + var getParamsArray = function(a) { var args = [ " " ]; - if (arguments.length > 0) { - if (arguments.length == 1 && Array.isArray(arguments[ 0 ])) { - if (arguments[ 0 ].length > 0) { - args = arguments[ 0 ]; + if (a && a.length > 0) { + if (a.length == 1 && Array.isArray(a[ 0 ])) { + if (a[ 0 ].length > 0) { + args = a[ 0 ]; } } else { - args = Array.prototype.slice.call(arguments); + args = Array.prototype.slice.call(a); } } + + return args; + }; + String.prototype.trimStart = function () { if (this.length === 0) { return this; } + var args = getParamsArray(arguments); var i = 0; for (; i < this.length && args.indexOf(this.charAt(i)) > -1; i++) { } return this.substring(i); }; String.prototype.trimEnd = function () { - var args = [ " " ]; - if (arguments.length > 0) { - if (arguments.length == 1 && Array.isArray(arguments[ 0 ])) { - if (arguments[ 0 ].length > 0) { - args = arguments[ 0 ]; - } - } else { - args = Array.prototype.slice.call(arguments); - } - } + var args = getParamsArray(arguments); var i = this.length - 1; for (; i >= 0 && args.indexOf(this.charAt(i)) > -1; i--) { } return this.substring(0, i + 1); @@ -3875,7 +3871,7 @@ String.isNullOrEmpty = function (s) { return !s || s.length < 1; }; String.isNullOrWhiteSpace = function (s) { return !s || s.trim().length < 1; }; String.empty = function () { return ""; }; - String.concat = function () { return [ ].join.call(arguments, ""); }; + String.concat = function () { return [ ].join.call(getParamsArray(arguments), ""); }; String.concat1 = function (o1, o2) { return [ ].join.call(arguments, ""); }; String.concat2 = function (s1, s2) { return [ ].join.call(arguments, ""); }; String.concat3 = function () { return [ ].join.call(arguments, ""); }; diff --git a/tests/unit/util/util-test.js b/tests/unit/util/util-test.js index 25afe59aa..380405927 100644 --- a/tests/unit/util/util-test.js +++ b/tests/unit/util/util-test.js @@ -424,4 +424,12 @@ QUnit.test('[ID20] Test OADate', function (assert) { var d1 = new Date(1999, 6, 4, 12, 0, 0); assert.equal(d1.toOADate(), 36345.5, "toOADate for " + d1); assert.equal($.ig.Date.prototype.fromOADate(36345.5).getTime(), +d1, "fromOADate to " + d1); +}); + +QUnit.test('[ID21] Test String.concat', function (assert) { + assert.expect(2); + + 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"); }); \ No newline at end of file