Make pad methods default to a chars of " " if chars is an empty string.

This commit is contained in:
John-David Dalton
2016-03-26 11:49:41 -07:00
parent 0f3338013e
commit 0dfe176fe6
2 changed files with 42 additions and 10 deletions

View File

@@ -4556,12 +4556,13 @@
function createPadding(string, length, chars) {
length = toInteger(length);
var strLength = stringSize(string);
var strLength = length ? stringSize(string) : 0;
if (!length || strLength >= length) {
return '';
}
var padLength = length - strLength;
chars = chars === undefined ? ' ' : (chars + '');
chars = chars == '' ? ' ' : chars;
var result = repeat(chars, nativeCeil(padLength / stringSize(chars)));
return reHasComplexSymbol.test(chars)
@@ -13044,7 +13045,7 @@
string = toString(string);
length = toInteger(length);
var strLength = stringSize(string);
var strLength = length ? stringSize(string) : 0;
if (!length || strLength >= length) {
return string;
}