Files
test-repo/changelog_unreleased/mdx/pr-6949.md
T

1.2 KiB

Fix JSX parsing bugs introduced in Prettier 1.19 (#6949 by @Tigge & @thorn0)

MDX parsing for JSX failed when encountering JSX elements that where not parsable as HTML, such as <Tag value={{a: 'b'}}>test</Tag>

<!-- Input -->

<Tag  value={ {a :  'b'   } }>test</ Tag>

<Foo bg={ 'red' } >
   <div  style={{   display:   'block'}   }>
      <Bar    >hi    </Bar>
       {  hello       }
         {     /* another comment */}
            </div>
</Foo>

<!-- Prettier stable -->

```
SyntaxError: Unexpected closing tag "Tag". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (1:35)
> 1 | <Tag  value={ {a :  'b'   } }>test</ Tag>
    |                                   ^
  2 |
  3 | <Foo bg={ 'red' } >
  4 |    <div  style={{   display:   'block'}   }>
```

<!-- Prettier master -->

<Tag value={{ a: "b" }}>test</Tag>

<Foo bg={"red"}>
  <div style={{ display: "block" }}>
    <Bar>hi </Bar>
    {hello}
    {/* another comment */}
  </div>
</Foo>