Skip to content

Commit 671b5cb

Browse files
authored
fix(949): fix unmatched closing tags in JSX with referenced identifiers (#1056)
1 parent af2ba73 commit 671b5cb

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

internal/transformers/utilities.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func isIdentifierReference(name *ast.IdentifierNode, parent *ast.Node) bool {
120120
return parent.AsImportAttribute().Value == name
121121
case ast.KindJsxOpeningElement:
122122
return parent.AsJsxOpeningElement().TagName == name
123+
case ast.KindJsxClosingElement:
124+
return parent.AsJsxClosingElement().TagName == name
123125
default:
124126
return false
125127
}

testdata/baselines/reference/submodule/conformance/inlineJsxFactoryDeclarations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4949
exports.prerendered = void 0;
5050
/** @jsx h */
5151
const renderer_1 = require("./renderer");
52-
exports.prerendered = <renderer_1.dom></h>;
52+
exports.prerendered = <renderer_1.dom></renderer_1.dom>;
5353
//// [othernoalias.js]
5454
"use strict";
5555
Object.defineProperty(exports, "__esModule", { value: true });

testdata/baselines/reference/submodule/conformance/inlineJsxFactoryDeclarations.js.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
-var renderer_1 = require("./renderer");
1717
-exports.prerendered = (0, renderer_1.dom)("h", null);
1818
+const renderer_1 = require("./renderer");
19-
+exports.prerendered = <renderer_1.dom></h>;
19+
+exports.prerendered = <renderer_1.dom></renderer_1.dom>;
2020
//// [othernoalias.js]
2121
"use strict";
2222
Object.defineProperty(exports, "__esModule", { value: true });

testdata/baselines/reference/submodule/conformance/inlineJsxFactoryDeclarationsLocalTypes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class MyClass {
109109
}
110110
}
111111
exports.MyClass = MyClass;
112-
exports.tree = <exports.MySFC x={1} y={2}><MyClass x={3} y={4}/><MyClass x={5} y={6}/></MySFC>;
112+
exports.tree = <exports.MySFC x={1} y={2}><MyClass x={3} y={4}/><MyClass x={5} y={6}/></exports.MySFC>;
113113
exports.default = <h></h>;
114114
//// [index.js]
115115
"use strict";
@@ -133,6 +133,6 @@ class DOMClass {
133133
// Should work, everything is a DOM element
134134
const _tree = <DOMSFC x={1} y={2}><DOMClass x={3} y={4}/><DOMClass x={5} y={6}/></DOMSFC>;
135135
// Should fail, no dom elements
136-
const _brokenTree = <component_1.MySFC x={1} y={2}><component_1.MyClass x={3} y={4}/><component_1.MyClass x={5} y={6}/></MySFC>;
136+
const _brokenTree = <component_1.MySFC x={1} y={2}><component_1.MyClass x={3} y={4}/><component_1.MyClass x={5} y={6}/></component_1.MySFC>;
137137
// Should fail, nondom isn't allowed as children of dom
138138
const _brokenTree2 = <DOMSFC x={1} y={2}>{component_1.tree}{component_1.tree}</DOMSFC>;

testdata/baselines/reference/submodule/conformance/inlineJsxFactoryDeclarationsLocalTypes.js.diff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
- (0, renderer2_1.predom)(MyClass, { x: 3, y: 4 }),
5656
- (0, renderer2_1.predom)(MyClass, { x: 5, y: 6 }));
5757
-exports.default = (0, renderer2_1.predom)("h", null);
58-
+exports.tree = <exports.MySFC x={1} y={2}><MyClass x={3} y={4}/><MyClass x={5} y={6}/></MySFC>;
58+
+exports.tree = <exports.MySFC x={1} y={2}><MyClass x={3} y={4}/><MyClass x={5} y={6}/></exports.MySFC>;
5959
+exports.default = <h></h>;
6060
//// [index.js]
6161
"use strict";
@@ -116,7 +116,7 @@
116116
-var _brokenTree = (0, renderer_1.dom)(component_1.MySFC, { x: 1, y: 2 },
117117
- (0, renderer_1.dom)(component_1.MyClass, { x: 3, y: 4 }),
118118
- (0, renderer_1.dom)(component_1.MyClass, { x: 5, y: 6 }));
119-
+const _brokenTree = <component_1.MySFC x={1} y={2}><component_1.MyClass x={3} y={4}/><component_1.MyClass x={5} y={6}/></MySFC>;
119+
+const _brokenTree = <component_1.MySFC x={1} y={2}><component_1.MyClass x={3} y={4}/><component_1.MyClass x={5} y={6}/></component_1.MySFC>;
120120
// Should fail, nondom isn't allowed as children of dom
121121
-var _brokenTree2 = (0, renderer_1.dom)(DOMSFC, { x: 1, y: 2 },
122122
- component_1.tree,

0 commit comments

Comments
 (0)