Skip to content
This repository was archived by the owner on Jan 14, 2019. It is now read-only.

Commit 833f218

Browse files
ikatyangJamesHenry
authored andcommitted
fix: correct JSXFragment fields (#34)
1 parent 8787f16 commit 833f218

File tree

3 files changed

+71
-14
lines changed

3 files changed

+71
-14
lines changed

src/convert.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -2089,8 +2089,8 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
20892089
case SyntaxKind.JsxFragment:
20902090
Object.assign(result, {
20912091
type: AST_NODE_TYPES.JSXFragment,
2092-
openingElement: convertChild((node as any).openingElement),
2093-
closingElement: convertChild((node as any).closingElement),
2092+
openingFragment: convertChild((node as ts.JsxFragment).openingFragment),
2093+
closingFragment: convertChild((node as ts.JsxFragment).closingFragment),
20942094
children: (node as any).children.map(convertChild)
20952095
});
20962096
break;
@@ -2136,8 +2136,7 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
21362136

21372137
case SyntaxKind.JsxOpeningFragment:
21382138
Object.assign(result, {
2139-
type: AST_NODE_TYPES.JSXOpeningFragment,
2140-
selfClosing: false
2139+
type: AST_NODE_TYPES.JSXOpeningFragment
21412140
});
21422141
break;
21432142
case SyntaxKind.JsxClosingFragment:

tests/ast-alignment/fixtures-to-test.ts

-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ const jsxFilesWithKnownIssues = jsxKnownIssues.map(f => f.replace('jsx/', ''));
3535
*/
3636
jsxFilesWithKnownIssues.push('invalid-no-tag-name');
3737

38-
/**
39-
* JSX shorthand fragments are not supported by Babylon
40-
*/
41-
jsxFilesWithKnownIssues.push('shorthand-fragment');
42-
jsxFilesWithKnownIssues.push('shorthand-fragment-with-child');
43-
4438
/**
4539
* Globally track which fixtures need to be parsed with sourceType: "module"
4640
* so that they can be added with the correct FixturePatternConfig

tests/lib/__snapshots__/jsx.ts.snap

+68-4
Original file line numberDiff line numberDiff line change
@@ -6832,7 +6832,23 @@ Object {
68326832
Object {
68336833
"expression": Object {
68346834
"children": Array [],
6835-
"closingElement": null,
6835+
"closingFragment": Object {
6836+
"loc": Object {
6837+
"end": Object {
6838+
"column": 5,
6839+
"line": 1,
6840+
},
6841+
"start": Object {
6842+
"column": 2,
6843+
"line": 1,
6844+
},
6845+
},
6846+
"range": Array [
6847+
2,
6848+
5,
6849+
],
6850+
"type": "JSXClosingFragment",
6851+
},
68366852
"loc": Object {
68376853
"end": Object {
68386854
"column": 5,
@@ -6843,7 +6859,23 @@ Object {
68436859
"line": 1,
68446860
},
68456861
},
6846-
"openingElement": null,
6862+
"openingFragment": Object {
6863+
"loc": Object {
6864+
"end": Object {
6865+
"column": 2,
6866+
"line": 1,
6867+
},
6868+
"start": Object {
6869+
"column": 0,
6870+
"line": 1,
6871+
},
6872+
},
6873+
"range": Array [
6874+
0,
6875+
2,
6876+
],
6877+
"type": "JSXOpeningFragment",
6878+
},
68476879
"range": Array [
68486880
0,
68496881
5,
@@ -7041,7 +7073,23 @@ Object {
70417073
"type": "JSXElement",
70427074
},
70437075
],
7044-
"closingElement": null,
7076+
"closingFragment": Object {
7077+
"loc": Object {
7078+
"end": Object {
7079+
"column": 12,
7080+
"line": 1,
7081+
},
7082+
"start": Object {
7083+
"column": 9,
7084+
"line": 1,
7085+
},
7086+
},
7087+
"range": Array [
7088+
9,
7089+
12,
7090+
],
7091+
"type": "JSXClosingFragment",
7092+
},
70457093
"loc": Object {
70467094
"end": Object {
70477095
"column": 12,
@@ -7052,7 +7100,23 @@ Object {
70527100
"line": 1,
70537101
},
70547102
},
7055-
"openingElement": null,
7103+
"openingFragment": Object {
7104+
"loc": Object {
7105+
"end": Object {
7106+
"column": 2,
7107+
"line": 1,
7108+
},
7109+
"start": Object {
7110+
"column": 0,
7111+
"line": 1,
7112+
},
7113+
},
7114+
"range": Array [
7115+
0,
7116+
2,
7117+
],
7118+
"type": "JSXOpeningFragment",
7119+
},
70567120
"range": Array [
70577121
0,
70587122
12,

0 commit comments

Comments
 (0)