esshorten icon indicating copy to clipboard operation
esshorten copied to clipboard

Fixes bug that was causing prefix to be added multiple times

Open joaosamouco opened this issue 8 years ago • 3 comments

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;
})();

joaosamouco avatar Apr 20 '16 15:04 joaosamouco

What happens when your prefix is "a"?

michaelficarra avatar Apr 20 '16 16:04 michaelficarra

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;
}());

joaosamouco avatar Apr 20 '16 16:04 joaosamouco

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.

joaosamouco avatar Apr 26 '16 09:04 joaosamouco