Skip to content

When any mj-selector element is present, <br> elements are sometimes compiled to <br></br> #3112

Description

@emma-k-alexandra

Describe the bug
<br> is getting compiled to different things based on if an mj-selector element is present in the MJML. It does not seem to matter if the mj-selector actually selects the block the <br> is in.

To Reproduce
Case 1: Example without mj-selector: https://mjml.io/try-it-live/To2DOPgd8

In this example,

...
<mj-text css-class="custom">
  <p>
    Hello World!<br>
  </p>
</mj-text>
...

is compiled to

...
<p> Hello World!<br>
</p>
...

Case 2: Example with mj-selector, <br> is compiled to <br></br>: https://mjml.io/try-it-live/vjWLQhb0L

In this example,

...
<mj-text css-class="custom">
  <p>
    Hello World!<br>
  </p>
</mj-text>
...

is compiled to

...
<p> Hello World!<br>
  </br></p>
...

Note that the path of the mj-selector does not actually select the mj-text the <br> is in.

Case 3: Example with mj-selector but <br> is compiled to <br />: https://mjml.io/try-it-live/mjLo-DtRrc

In this example, the <br> is not placed in a <p>.

...
<mj-text css-class="custom">
  Hello World!<br>
</mj-text>
...

is compiled to

...
Hello World!<br />
...

Again, the path of the mj-selector does not actually select the mj-text the <br> is in.

Expected behavior
Adding an mj-selector should not change what <br> is compiled to.

MJML environment (please complete the following information):

  • MJML Version 5.3.0
  • MJML tool used Try it Live

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions