Skip to content

Commit

Permalink
fix(es/typescript): Fix handling of non-uppercase JSX elements (#6928)
Browse files Browse the repository at this point in the history
**Related issue:**

 - Closes #6923.
  • Loading branch information
kdy1 committed Feb 10, 2023
1 parent b9212cf commit ebc65c7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/swc_ecma_transforms_typescript/src/strip.rs
Expand Up @@ -1629,7 +1629,7 @@ where
fn visit_jsx_element_name(&mut self, n: &JSXElementName) {
match n {
JSXElementName::Ident(i) => {
if i.sym.starts_with(|c: char| c.is_ascii_uppercase()) {
if i.sym.starts_with(|c: char| !c.is_ascii_lowercase()) {
n.visit_children_with(self);
}
}
Expand Down Expand Up @@ -2083,7 +2083,7 @@ where
fn visit_mut_jsx_element_name(&mut self, n: &mut JSXElementName) {
match n {
JSXElementName::Ident(i) => {
if i.sym.starts_with(|c: char| c.is_ascii_uppercase()) {
if i.sym.starts_with(|c: char| !c.is_ascii_lowercase()) {
n.visit_mut_children_with(self);
}
}
Expand Down
@@ -0,0 +1,11 @@
import React from "react";
import ReactDOM from "react-dom";
import { _Component } from "./Component";

const App = (
<div>
<_Component></_Component>
<p>Hello World</p>
</div>
);
ReactDOM.render(App, window.document.getElementById("react_root"));
@@ -0,0 +1,10 @@
import ReactDOM from "react-dom";
import { _Component } from "./Component";
const App = <div>

<_Component></_Component>

<p>Hello World</p>

</div>;
ReactDOM.render(App, window.document.getElementById("react_root"));

0 comments on commit ebc65c7

Please sign in to comment.