madskristensen / BundlerMinifier

Visual Studio extension
Other
611 stars 171 forks source link

Doesn't cope with nested for loops #557

Open ukandrewc opened 3 years ago

ukandrewc commented 3 years ago

Doesn't cope with nested for loops, gives the same variable name to all.

Original

for (const table of document.getElementsByTagName("table")) {
    table.style.tableLayout = "fixed"
    for (const row of table.rows) {
        for (const cel of row.cells) {
            cel.style.border = "1px solid " + choose(1 + Math.random() * 5, ["red", "green", "gold", "blue", "orange"])
        }
    }
}

function choose(n,l) {
    return l[Math.round(n) - 1]
}

Minified

function choose(n,t){return t[Math.round(n)-1]}for(const n of document.getElementsByTagName("table")){n.style.tableLayout="fixed";for(const n of n.rows)for(const n of n.cells)n.style.border="1px solid "+choose(1+Math.random()*5,["red","green","gold","blue","orange"])}