Skip to content

Allow to configure the "custom elements as inline elements" behavior #2113

Closed
@cexbrayat

Description

@cexbrayat

Description

Hi team! And thank you for your work on js-beautify.

I'm part of the Vue core team, and I'm one of the maintainers of the Vue Test Utils library. We use js-beautify in VTU to make the tested HTML prettier in the output. So for example, you can test something like:

expect(wrapper.html()).toBe(`<div>
  <h1>Hello</h1>
</div>`);  // the `html()` method formats the HTML with js-beautify

There are thousands of tests out there that use this (VTU has 1.3 million downloads per week).

js-beautify v1.14.7 introduced a new behavior in aa82eb9 which is quite breaking for us, as all elements with a dash are now wrapped differently. And VTU uses elements with a -stub suffix when stubbing components, so a test that would usually succeed like:

expect(wrapper.html()).toBe(`<child-stub>
  <h1>Hello</h1>
</child-stub>`);

now fails if we update to v1.14.7 as the output of js-beautify is now <child-stub><h1>Hello</h1></child-stub>.

You can see that a lot of the VTU tests are failing when trying to bump to the new version of js-beautify here.

It would be awesome if we could configure this behavior to disable it and keep the output as it was in VTU, thus avoiding the developers that use VTU having to update all their tests, or us getting stuck on v1.14.6.

A new option like custom_element_as_inline_element (that could be true by default, but that we could switch to false to restore the previous behavior) would be very helpful.

Do you think that can be possible?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions