Skip to content

Commit

Permalink
Fix custom elements
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 13, 2022
1 parent e959615 commit ddcebdb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/plugin/recma-jsx-rewrite.js
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions test/core.js
Expand Up @@ -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: []})
]
})
)
)
),
'<a-b></a-b>',
'should compile custom elements'
)

t.equal(
renderToStaticMarkup(
React.createElement(
Expand Down

0 comments on commit ddcebdb

Please sign in to comment.