esshorten
esshorten copied to clipboard
Fixes bug that was causing prefix to be added multiple times
This bug was introduced by our PR #18. It was causing the namePrefix to be added multiple times to renamed variables in some scenarios (ie: IIFE).
Here is an example of what was happening:
(function () {
var variableA = 1;
var variableB = 2;
var variableC = 3;
})();
When we mangled the tree with _
as namePrefix:
(function () {
var _a = 1;
var __b = 2;
var ___c = 3;
})();
What happens when your prefix is "a"
?
Just tested it and this is the output of the same example with a
as prefix.
(function () {
var aa = 1;
var ab = 2;
var ac = 3;
}());
Took your comment in to consideration and moved the condition outside of the loop.
Tell me if you find something else that can be improved.