Skip to content

formatElements fails with multiple uses of same tag in same scope #593

Closed
@dannysellers

Description

@dannysellers

Bug Description
When formatting a string with multiple usages of the same component in the same scope, formatElements only considers the outermost opening and closing tags

To Reproduce
Use a Trans tag like <Trans id="<0>Superscript</0> regular <0>super</0>" components=[{<sup />}] />, observe rendered HTML is <sup>Superscript&lt;/0&gt; regular &lt;0&gt;super</sup>

it("should format multiple usages of same element in the same scope", function() {
  expect(
    html(formatElements("<0>First</0> second <0>third</0> <0>fourth</0>", [<sup />]))
  ).toEqual(
   wrap("<sup>First</sup> second <sup>third</sup> <sup>fourth</sup>")
  )
})

Expected behavior
The formatter should correctly replace multiple instances of the same component

  • jsLingui version 2.8.3
  • Babel version 6.26.3
  • This issue affects a project created with simple-react-app, but also affects Lingui's master

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