Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix self-closing tag to match with react-i18next #663

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lexers/jsx-lexer.js
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
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