From 7e604e7d666bcc9ec0d4a27f9db5950d6ee00726 Mon Sep 17 00:00:00 2001 From: Duknam Yoo Date: Mon, 24 Oct 2022 15:49:22 +0900 Subject: [PATCH] Fix self-closing tag to match with react-i18next --- src/lexers/jsx-lexer.js | 2 +- test/lexers/jsx-lexer.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lexers/jsx-lexer.js b/src/lexers/jsx-lexer.js index eba68964..147a8bbe 100644 --- a/src/lexers/jsx-lexer.js +++ b/src/lexers/jsx-lexer.js @@ -170,7 +170,7 @@ export default class JsxLexer extends JavascriptLexer { const childrenString = elemsToString(child.children) return childrenString || !(useTagName && child.selfClosing) ? `<${elementName}>${childrenString}` - : `<${elementName} />` + : `<${elementName}/>` default: throw new Error('Unknown parsed content: ' + child.type) } diff --git a/test/lexers/jsx-lexer.test.js b/test/lexers/jsx-lexer.test.js index 41cf7744..8519684f 100644 --- a/test/lexers/jsx-lexer.test.js +++ b/test/lexers/jsx-lexer.test.js @@ -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 = 'a
b
' - assert.equal(Lexer.extract(content)[0].defaultValue, 'a
b') + assert.equal(Lexer.extract(content)[0].defaultValue, 'a
b') done() })