unjquerify icon indicating copy to clipboard operation
unjquerify copied to clipboard

Unchaining adds superfluous newlines

Open devbridie opened this issue 6 years ago • 0 comments

When transforming $("a").hide().hide().hide().hide(), extra newlines will be inserted between each output statement, resulting in the following:

const element = document.querySelectorAll("a");

element.style.display = "none";

element.style.display = "none";

...

As the output will be very verbose with many chained statements, this is undesirable. When removing the outer callExpression so that the outer expression is a memberExpression, no newlines seem to be inserted.

Possible babel-core bug. See related issue.

What is exceptional is that each statement separately will not generate a newline when used with babel-generate to output each statement, however, joining them with insertBefore, insertAfter, or replaceWithMultiple with or without the use of a BlockStatement will cause them to appear.

  • [ ] Create reproduction case on AST Explorer.
  • [ ] Bug report?

devbridie avatar Jun 26 '18 04:06 devbridie