PerimeterX/restringer

unwrapIIFEs does not respect order

Opened this issue · 1 comments

unwrapIIFEs just adds the function body to the end of the body of the parent. Take:

var b = 2
void !function () {
    b = 1;
}();
console.log(b)

This becomes

var b = 2;
console.log(b);
b = 1;

I am opening a merge request to address this.

@jorants I really appreciate you bringing up this issue and going so far as creating a PR!
Honestly, I'm thinking of disabling this module, as I'm not sure that putting the IIFE's code in its parent context is the right way to go, so I'd appreciate your input regarding its usefulness.