So as promised, I tested Butternut with more minified libraries. Current victim is the honorable 6to5 library.
Butternut fails on it, and this time (after actually installing butternut on my PC) I was clever enough to hunt down the cause.
In essence, this fails:
function fn_1 () {
if ( !any_condition ) {
fn_2()
} else {
fn_3()
}return true
}
This fails because Buttercup does not combine two of its behaviours correctly:
The negated condition will be reformed into a ternary operator, removing the negating exclamation mark and consequentially swapping places of function calls fn_2() and fn_3().
If there is no whitespace or semicolon between the end of the else block and the following statement, a semicolon will be inserted between them.
The issue is that it gets the order of those operations wrong, first adding the semicolon and swapping ternary operator statements after that, producing the following invalid code:
function fn_1(){any_condition?fn_3();:fn_2()return !0}
So as promised, I tested Butternut with more minified libraries. Current victim is the honorable 6to5 library.
Butternut fails on it, and this time (after actually installing butternut on my PC) I was clever enough to hunt down the cause.
In essence, this fails:
This fails because Buttercup does not combine two of its behaviours correctly:
fn_2()
andfn_3()
.else
block and the following statement, a semicolon will be inserted between them.The issue is that it gets the order of those operations wrong, first adding the semicolon and swapping ternary operator statements after that, producing the following invalid code: