Skip to content

Commit 128118c

Browse files
authored
Merge pull request #481 from asger-semmle/typescript-jsx
Approved by xiemaisi
2 parents 47b9218 + a35061e commit 128118c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

javascript/extractor/src/com/semmle/js/parser/TypeScriptASTConverter.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,23 +1385,26 @@ private Node convertJsxClosingFragment(JsonObject node, SourceLocation loc) {
13851385
return new JSXClosingElement(loc, null);
13861386
}
13871387

1388-
private Node convertJsxOpeningElement(JsonObject node, SourceLocation loc) throws ParseError {
1388+
private List<IJSXAttribute> convertJsxAttributes(JsonObject node) throws ParseError {
13891389
JsonElement attributes = node.get("attributes");
13901390
List<IJSXAttribute> convertedAttributes;
13911391
if (attributes.isJsonArray()) {
13921392
convertedAttributes = convertNodes(attributes.getAsJsonArray());
13931393
} else {
13941394
convertedAttributes = convertChildren(attributes.getAsJsonObject(), "properties");
13951395
}
1396+
return convertedAttributes;
1397+
}
1398+
1399+
private Node convertJsxOpeningElement(JsonObject node, SourceLocation loc) throws ParseError {
1400+
List<IJSXAttribute> convertedAttributes = convertJsxAttributes(node);
13961401
return new JSXOpeningElement(loc, convertJSXName(convertChild(node, "tagName")), convertedAttributes, hasChild(node, "selfClosing"));
13971402
}
13981403

1399-
private Node convertJsxSelfClosingElement(JsonObject node,
1400-
SourceLocation loc) throws ParseError {
1401-
node.remove("kind");
1402-
node.add("kind", syntaxKinds.get("JsxOpeningElement"));
1403-
node.add("selfClosing", new JsonPrimitive(true));
1404-
return new JSXElement(loc, (JSXOpeningElement) convertNode(node), new ArrayList<>(), null);
1404+
private Node convertJsxSelfClosingElement(JsonObject node, SourceLocation loc) throws ParseError {
1405+
List<IJSXAttribute> convertedAttributes = convertJsxAttributes(node);
1406+
JSXOpeningElement opening = new JSXOpeningElement(loc, convertJSXName(convertChild(node, "tagName")), convertedAttributes, true);
1407+
return new JSXElement(loc, opening, new ArrayList<>(), null);
14051408
}
14061409

14071410
private Node convertJsxSpreadAttribute(JsonObject node,

0 commit comments

Comments
 (0)