Remove usage of non-standard Array methods.

This commit is contained in:
hackademix 2019-02-01 01:17:58 +01:00
parent d152a53871
commit 0878ad2b0a
4 changed files with 10 additions and 11 deletions

View File

@ -31,7 +31,7 @@
headCells[i].addEventListener("click", rowAction(i), true); headCells[i].addEventListener("click", rowAction(i), true);
} }
if (gUI_showHidden) { if (gUI_showHidden) {
gRows = Array.slice(gTBody.rows); gRows = Array.from(gTBody.rows);
hiddenObjects = gRows.some(row => row.className == "hidden-object"); hiddenObjects = gRows.some(row => row.className == "hidden-object");
} }
gTable.setAttribute("order", ""); gTable.setAttribute("order", "");
@ -60,7 +60,7 @@
} }
function orderBy(column) { function orderBy(column) {
if (!gRows) if (!gRows)
gRows = Array.slice(gTBody.rows); gRows = Array.from(gTBody.rows);
var order; var order;
if (gOrderBy == column) { if (gOrderBy == column) {
order = gTable.getAttribute("order") == "asc" ? "desc" : "asc"; order = gTable.getAttribute("order") == "asc" ? "desc" : "asc";

View File

@ -7,12 +7,12 @@ if (typeof flextabs === "function") {
let rx = new RegExp(`(?:^|[#;])tab-${id}=(\\d+)(?:;|$)`); let rx = new RegExp(`(?:^|[#;])tab-${id}=(\\d+)(?:;|$)`);
let current = location.hash.match(rx); let current = location.hash.match(rx);
console.log(`persisted %o`, current); console.log(`persisted %o`, current);
let toggles = tabs.querySelectorAll(".flextabs__toggle"); let toggles = Array.from(tabs.querySelectorAll(".flextabs__toggle"));
let currentToggle = toggles[current && parseInt(current[1]) || 0]; let currentToggle = toggles[current && parseInt(current[1]) || 0];
if (currentToggle) currentToggle.click(); if (currentToggle) currentToggle.click();
for (let toggle of toggles) { for (let toggle of toggles) {
toggle.addEventListener("click", e => { toggle.addEventListener("click", e => {
let currentIdx = Array.indexOf(toggles, toggle); let currentIdx = toggles.indexOf(toggle);
location.hash = location.hash.split(";").filter(p => !rx.test(p)) location.hash = location.hash.split(";").filter(p => !rx.test(p))
.concat(`tab-${id}=${currentIdx}`).join(";"); .concat(`tab-${id}=${currentIdx}`).join(";");
}); });

View File

@ -87,7 +87,7 @@
} }
UI.local.toolbarLayout = { UI.local.toolbarLayout = {
left, right, left, right,
hidden: Array.map(document.querySelectorAll("#top > .hider > .icon"), el => el.id), hidden: Array.from(document.querySelectorAll("#top > .hider > .icon")).map(el => el.id),
}; };
debug("%o", UI.local); debug("%o", UI.local);

View File

@ -107,11 +107,10 @@ XSS.InjectionChecker = (async () => {
var bs = { var bs = {
nq: new RegExp("[" + def + "]") nq: new RegExp("[" + def + "]")
}; };
Array.forEach("'\"`", // special treatment for quotes for (let c of ['"', '"', '`']) {
function(c) { // special treatment for quotes
bs[c] = new RegExp("[" + def + c + "]"); bs[c] = new RegExp("[" + def + c + "]");
} }
);
delete this.breakStops; delete this.breakStops;
return (this.breakStops = bs); return (this.breakStops = bs);
}, },