Minify Js error
han-jingyu opened this issue · comments
Han JingYu commented
The source:
var div = document.createElement("div");
var c = "";
for (let i = 0; i < 5; i++) {
c += '.....';
}
div.innerHTML = c;
Sometime, it will be compress to:
var div = document.createElement("div");
for (let c="", i = 0; i < 5; i++) {
c += '.....';
}
div.innerHTML = c;
The c cannot be used outside for.
Taco de Wolff commented
Hi Han, thank you for reporting this issue. I'm a bit confused by what you mean with "sometime", do you mean that the minification result changes every time you minify it, sometimes it is correct and sometimes not? Or do you mean that similar JS code in another part do work but this one doesn't? If it is non-deterministic, that would be really strange...
For me it outputs:
var div=document.createElement("div"),c="";for(let e=0;e<5;e++)c+=".....";div.innerHTML=c
What version do you use of minify
?
Han JingYu commented
Taco de Wolff commented
Thanks again! This should now be fixed in the latest version, can you please verify?