diff --git a/src/lexers/jsx-lexer.js b/src/lexers/jsx-lexer.js index da9a3800..9b5dd5c4 100644 --- a/src/lexers/jsx-lexer.js +++ b/src/lexers/jsx-lexer.js @@ -225,7 +225,9 @@ export default class JsxLexer extends JavascriptLexer { const name = element.tagName.escapedText const isBasic = !element.attributes.properties.length const hasDynamicChildren = element.attributes.properties.find( - (prop) => prop.name.escapedText === 'i18nIsDynamicList' + (prop) => + prop.kind === ts.SyntaxKind.JsxAttribute && + prop.name.escapedText === 'i18nIsDynamicList' ) return { type: 'tag', diff --git a/test/lexers/jsx-lexer.test.js b/test/lexers/jsx-lexer.test.js index e1745d95..e4eaa8d0 100644 --- a/test/lexers/jsx-lexer.test.js +++ b/test/lexers/jsx-lexer.test.js @@ -275,6 +275,17 @@ describe('JsxLexer', () => { done() }) + it('handles spread attributes', (done) => { + const Lexer = new JsxLexer() + const content = + 'My dog is named: Spot' + assert.equal( + Lexer.extract(content)[0].defaultValue, + 'My dog is named: <1>Spot' + ) + done() + }) + it('erases comment expressions', (done) => { const Lexer = new JsxLexer() const content = '{/* some comment */}Some Content'