Skip to content

Commit ddcebdb

Browse files
committed
Fix custom elements
Related-to: remarkjs/remark-math#72.
1 parent e959615 commit ddcebdb

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/plugin/recma-jsx-rewrite.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ export function recmaJsxRewrite(options = {}) {
219219
defaults.push({
220220
type: 'Property',
221221
kind: 'init',
222-
key: {type: 'Identifier', name},
222+
key: isIdentifierName(name)
223+
? {type: 'Identifier', name}
224+
: {type: 'Literal', value: name},
223225
value: {type: 'Literal', value: name},
224226
method: false,
225227
shorthand: false,

test/core.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ test('xdm', async (t) => {
103103
'should compile a non-element document (rehype, single element)'
104104
)
105105

106+
t.equal(
107+
renderToStaticMarkup(
108+
React.createElement(
109+
await run(
110+
compileSync('y', {
111+
rehypePlugins: [
112+
() => () => ({type: 'element', tagName: 'a-b', children: []})
113+
]
114+
})
115+
)
116+
)
117+
),
118+
'<a-b></a-b>',
119+
'should compile custom elements'
120+
)
121+
106122
t.equal(
107123
renderToStaticMarkup(
108124
React.createElement(

0 commit comments

Comments
 (0)