Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and discussions and couldn’t find anything (or linked relevant results below)
Problem
JsxMemberExpression
should support computed member expression (with bracket notation) in opening tag names in jsx.
I opened an issue in facebook/jsx which explains the issue in specification.
I see that recma
is super powerful more than I think. I've created a recma
plugin recma-mdx-html-override
to allow specific html raw elements overridable via mdx components. The only remaining gap is for the tag names with hypen like <custom-tag />
in mdx when jsx: true
in the mdx options. Since the recma-mdx-html-override
makes the tag callable via <_components.custom-tag />
, actually should be <_components["custom-tag"] />
instead.
Current solutions
Currently, the jsxMemberExpression
is:
function jsxMemberExpression(node, state) {
this[node.object.type](node.object, state)
state.write('.')
this[node.property.type](node.property, state)
}
Proposed solutions
I suppose we need just to extend the JSXMemberExpression
adding a computed
property. Then,
function jsxMemberExpression(node, state) {
this[node.object.type](node.object, state)
if (!node.computed) state.write('.')
if (node.computed) state.write('[')
this[node.property.type](node.property, state)
if (node.computed) state.write(']')
}
My intention was to create a custom handler for that, but compile
of @mdx-js/mdx
doesn't except any handler
/or handlers
option to be passed into recma-stringfy
hence to estree-util-to-js
.