diff options
| author | Paul Donald | 2026-02-18 15:32:43 +0000 |
|---|---|---|
| committer | Paul Donald | 2026-02-18 15:32:43 +0000 |
| commit | ad057c1491810d0bf9dc6848907c78195e683c0f (patch) | |
| tree | 6d193b75c9a063811a9fab3e6b9c8d7e80823714 | |
| parent | d28ebe176474195f2aefe9d44049327ff003c5b5 (diff) | |
| download | luci-ad057c1491810d0bf9dc6848907c78195e683c0f.tar.gz | |
luci-base: js linting fixes / ES6 treatment
follow-up to 50a8d5325db0b631bc86f9e3f375d1473fd4149c
resolve array args correctly in String.prototype functions.
Also fix a sneaky bug in padding.
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
| -rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 1a637dcd68..e2c9e4e924 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -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); } |