mirror of
https://github.com/openwrt/luci.git
synced 2026-06-17 14:50:21 +04:00
luci-base: js linting fixes / ES6 treatment
follow-up to 50a8d5325d
resolve array args correctly in String.prototype functions.
Also fix a sneaky bug in padding.
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
@@ -680,6 +680,7 @@ String.prototype.format = function()
|
||||
const m = a[1];
|
||||
let leftpart = a[2], pPad = a[3], pJustify = a[4], pMinLength = a[5];
|
||||
let pPrecision = a[6], pType = a[7];
|
||||
let precision;
|
||||
|
||||
if (pType == '%') {
|
||||
subst = '%';
|
||||
@@ -690,13 +691,13 @@ String.prototype.format = function()
|
||||
|
||||
pad = '';
|
||||
if (pPad && pPad.substr(0,1) == "'")
|
||||
pad = leftpart.substr(1,1);
|
||||
pad = pPad.substr(1,1);
|
||||
else if (pPad)
|
||||
pad = pPad;
|
||||
else
|
||||
pad = ' ';
|
||||
|
||||
var precision = -1;
|
||||
precision = -1;
|
||||
if (pPrecision && pType == 'f')
|
||||
precision = +pPrecision.substring(1);
|
||||
|
||||
@@ -838,8 +839,9 @@ String.format = function()
|
||||
{
|
||||
const a = [ ];
|
||||
|
||||
for (let ar of arguments)
|
||||
a.push(ar);
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
a.push(arguments[i]);
|
||||
}
|
||||
|
||||
return ''.format.apply(arguments[0], a);
|
||||
}
|
||||
@@ -855,8 +857,8 @@ String.nobr = function()
|
||||
{
|
||||
const a = [ ];
|
||||
|
||||
for (let ar of arguments)
|
||||
a.push(ar);
|
||||
for (let i = 1; i < arguments.length; i++)
|
||||
a.push(arguments[i]);
|
||||
|
||||
return ''.nobr.apply(arguments[0], a);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user