Skip to content

Unchaining adds superfluous newlines #9

@devbridie

Description

@devbridie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengine

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions