Skip to content

Commit ebc65c7

Browse files
authoredFeb 10, 2023
fix(es/typescript): Fix handling of non-uppercase JSX elements (#6928)
**Related issue:** - Closes #6923.
1 parent b9212cf commit ebc65c7

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed
 

‎crates/swc_ecma_transforms_typescript/src/strip.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ where
16291629
fn visit_jsx_element_name(&mut self, n: &JSXElementName) {
16301630
match n {
16311631
JSXElementName::Ident(i) => {
1632-
if i.sym.starts_with(|c: char| c.is_ascii_uppercase()) {
1632+
if i.sym.starts_with(|c: char| !c.is_ascii_lowercase()) {
16331633
n.visit_children_with(self);
16341634
}
16351635
}
@@ -2083,7 +2083,7 @@ where
20832083
fn visit_mut_jsx_element_name(&mut self, n: &mut JSXElementName) {
20842084
match n {
20852085
JSXElementName::Ident(i) => {
2086-
if i.sym.starts_with(|c: char| c.is_ascii_uppercase()) {
2086+
if i.sym.starts_with(|c: char| !c.is_ascii_lowercase()) {
20872087
n.visit_mut_children_with(self);
20882088
}
20892089
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
import ReactDOM from "react-dom";
3+
import { _Component } from "./Component";
4+
5+
const App = (
6+
<div>
7+
<_Component></_Component>
8+
<p>Hello World</p>
9+
</div>
10+
);
11+
ReactDOM.render(App, window.document.getElementById("react_root"));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ReactDOM from "react-dom";
2+
import { _Component } from "./Component";
3+
const App = <div>
4+
5+
<_Component></_Component>
6+
7+
<p>Hello World</p>
8+
9+
</div>;
10+
ReactDOM.render(App, window.document.getElementById("react_root"));

0 commit comments

Comments
 (0)
Please sign in to comment.