Skip to content

Commit f3e83f3

Browse files
authored
Handle dashes in JSXIdentifier's (#205)
* Handle dashes in JSXIdentifier's * Add unit test
1 parent dff604e commit f3e83f3

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src-transpiler/Stringifier.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,11 @@ class Stringifier {
11811181
JSXIdentifier(node) {
11821182
const {name} = node;
11831183
// console.log('JSXIdentifier', {name});
1184+
// https://github.com/kungfooman/RuntimeTypeInspector.js/issues/201
1185+
// https://stackoverflow.com/questions/38998987/using-aria-attributes-on-elements-in-react
1186+
if (name.includes('-')) {
1187+
return JSON.stringify(name);
1188+
}
11841189
return name;
11851190
}
11861191
/**

test/typechecking.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
"input": "./test/typechecking/jsdoc-regexp-default-values-sci-input.mjs",
8080
"output": "./test/typechecking/jsdoc-regexp-default-values-sci-output.mjs"
8181
},
82+
{
83+
"input": "./test/typechecking/jsx-dash-identifier-input.mjs",
84+
"output": "./test/typechecking/jsx-dash-identifier-output.mjs"
85+
},
8286
{
8387
"input": "./test/typechecking/jsx-input.mjs",
8488
"output": "./test/typechecking/jsx-output.mjs"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<svg aria-hidden="true"></svg>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {createElement} from 'react';
2+
createElement(
3+
"svg",
4+
{
5+
"aria-hidden": "true",
6+
}
7+
);

0 commit comments

Comments
 (0)