Skip to content

Commit

Permalink
Fix self-closing tag to match with react-i18next
Browse files Browse the repository at this point in the history
  • Loading branch information
yoo2001818 committed Oct 24, 2022
1 parent 3450253 commit 7e604e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lexers/jsx-lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class JsxLexer extends JavascriptLexer {
const childrenString = elemsToString(child.children)
return childrenString || !(useTagName && child.selfClosing)
? `<${elementName}>${childrenString}</${elementName}>`
: `<${elementName} />`
: `<${elementName}/>`
default:
throw new Error('Unknown parsed content: ' + child.type)
}
Expand Down
2 changes: 1 addition & 1 deletion test/lexers/jsx-lexer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe('JsxLexer', () => {
it('keeps self-closing tags untouched when transSupportBasicHtmlNodes is true', (done) => {
const Lexer = new JsxLexer({ transSupportBasicHtmlNodes: true })
const content = '<Trans>a<br />b</Trans>'
assert.equal(Lexer.extract(content)[0].defaultValue, 'a<br />b')
assert.equal(Lexer.extract(content)[0].defaultValue, 'a<br/>b')
done()
})

Expand Down

0 comments on commit 7e604e7

Please sign in to comment.