diff --git a/lib/plugin/recma-jsx-rewrite.js b/lib/plugin/recma-jsx-rewrite.js index c89b5ee..27f2ec3 100644 --- a/lib/plugin/recma-jsx-rewrite.js +++ b/lib/plugin/recma-jsx-rewrite.js @@ -219,7 +219,9 @@ export function recmaJsxRewrite(options = {}) { defaults.push({ type: 'Property', kind: 'init', - key: {type: 'Identifier', name}, + key: isIdentifierName(name) + ? {type: 'Identifier', name} + : {type: 'Literal', value: name}, value: {type: 'Literal', value: name}, method: false, shorthand: false, diff --git a/test/core.js b/test/core.js index 500d964..b17c304 100644 --- a/test/core.js +++ b/test/core.js @@ -103,6 +103,22 @@ test('xdm', async (t) => { 'should compile a non-element document (rehype, single element)' ) + t.equal( + renderToStaticMarkup( + React.createElement( + await run( + compileSync('y', { + rehypePlugins: [ + () => () => ({type: 'element', tagName: 'a-b', children: []}) + ] + }) + ) + ) + ), + '', + 'should compile custom elements' + ) + t.equal( renderToStaticMarkup( React.createElement(