Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3409,19 +3409,19 @@ function lowerJsxElementName(
const exprLoc = exprNode.loc ?? GeneratedSource;
if (exprPath.isJSXIdentifier()) {
const tag: string = exprPath.node.name;
if (tag.match(/^[A-Z]/)) {
if (tag.match(/^[a-z]/)) {
return {
kind: 'BuiltinTag',
name: tag,
loc: exprLoc,
};
} else {
const kind = getLoadKind(builder, exprPath);
return lowerValueToTemporary(builder, {
kind: kind,
place: lowerIdentifier(builder, exprPath),
loc: exprLoc,
});
} else {
return {
kind: 'BuiltinTag',
name: tag,
loc: exprLoc,
};
}
} else if (exprPath.isJSXMemberExpression()) {
return lowerJsxMemberExpression(builder, exprPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

## Input

```javascript
import {Stringify} from 'shared-runtime';

// Repro for #36601: an underscore-prefixed JSX tag (`<_Bar>`) is a component
// reference, not a host/builtin element. Before the fix, `lowerJsxElementName`
// used `/^[A-Z]/` to detect components, so `_Bar` (which is not A-Z) was lowered
// as a BuiltinTag — emitting the literal string tag "_Bar" instead of loading
// the `_Bar` binding. The compiled output below must reference the `_Bar`
// identifier (component), not a string tag.
function Foo({_Bar}: {_Bar: React.ComponentType<{children: React.ReactNode}>}) {
return <_Bar>ok</_Bar>;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{_Bar: Stringify}],
};

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
import { Stringify } from "shared-runtime";

// Repro for #36601: an underscore-prefixed JSX tag (`<_Bar>`) is a component
// reference, not a host/builtin element. Before the fix, `lowerJsxElementName`
// used `/^[A-Z]/` to detect components, so `_Bar` (which is not A-Z) was lowered
// as a BuiltinTag — emitting the literal string tag "_Bar" instead of loading
// the `_Bar` binding. The compiled output below must reference the `_Bar`
// identifier (component), not a string tag.
function Foo(t0) {
const $ = _c(2);
const { _Bar } = t0;
let t1;
if ($[0] !== _Bar) {
t1 = <_Bar>ok</_Bar>;
$[0] = _Bar;
$[1] = t1;
} else {
t1 = $[1];
}
return t1;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{ _Bar: Stringify }],
};

```

### Eval output
(kind: ok) <div>{"children":"ok"}</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Stringify} from 'shared-runtime';

// Repro for #36601: an underscore-prefixed JSX tag (`<_Bar>`) is a component
// reference, not a host/builtin element. Before the fix, `lowerJsxElementName`
// used `/^[A-Z]/` to detect components, so `_Bar` (which is not A-Z) was lowered
// as a BuiltinTag — emitting the literal string tag "_Bar" instead of loading
// the `_Bar` binding. The compiled output below must reference the `_Bar`
// identifier (component), not a string tag.
function Foo({_Bar}: {_Bar: React.ComponentType<{children: React.ReactNode}>}) {
return <_Bar>ok</_Bar>;
}

export const FIXTURE_ENTRYPOINT = {
fn: Foo,
params: [{_Bar: Stringify}],
};