Skip to content

Commit 7c864c9

Browse files
authored
[compiler][ez] Patch for JSX escape sequences in @babel/generator (#32131)
Fall back to using JSXExpressionContainer for strings potentially containing escape sequences (a single backslash) to fix #32123. This is an extension of #29079
1 parent 1955744 commit 7c864c9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Diff for: compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ function codegenInstructionValue(
22692269
* https://en.wikipedia.org/wiki/List_of_Unicode_characters#Control_codes
22702270
*/
22712271
const STRING_REQUIRES_EXPR_CONTAINER_PATTERN =
2272-
/[\u{0000}-\u{001F}\u{007F}\u{0080}-\u{FFFF}]|"/u;
2272+
/[\u{0000}-\u{001F}\u{007F}\u{0080}-\u{FFFF}]|"|\\/u;
22732273
function codegenJsxAttribute(
22742274
cx: Context,
22752275
attribute: JsxAttribute,

Diff for: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-escape-character.expect.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function MyApp() {
3838
const $ = _c(1);
3939
let t0;
4040
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
41-
t0 = <input pattern="\\w" />;
41+
t0 = <input pattern={"\\w"} />;
4242
$[0] = t0;
4343
} else {
4444
t0 = $[0];

Diff for: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-propagate-type-of-ternary-nested.expect.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,23 @@ function V0(t0) {
4242
<ComponentC cd="TxqUy" ce="oh`]uc" cf="Bdbo" c10={!V9.va && v11.v12}>
4343
gmhubcw
4444
{v1 === V3.V13 ? (
45-
<c14 c15="L^]w\\\\T\\\\qrGmqrlQyrvBgf\\\\inuRdkEqwVPwixiriYGSZmKJf]E]RdT{N[WyVPiEJIbdFzvDohJV[BV`H[[K^xoy[HOGKDqVzUJ^h">
45+
<c14
46+
c15={
47+
"L^]w\\\\T\\\\qrGmqrlQyrvBgf\\\\inuRdkEqwVPwixiriYGSZmKJf]E]RdT{N[WyVPiEJIbdFzvDohJV[BV`H[[K^xoy[HOGKDqVzUJ^h"
48+
}
49+
>
4650
iawyneijcgamsfgrrjyvhjrrqvzexxwenxqoknnilmfloafyvnvkqbssqnxnexqvtcpvjysaiovjxyqrorqskfph
4751
</c14>
4852
) : v16.v17("pyorztRC]EJzVuP^e") ? (
49-
<c14 c15="CRinMqvmOknWRAKERI]RBzB_LXGKQe{SUpoN[\\\\gL[`bLMOhvFqDVVMNOdY">
53+
<c14
54+
c15={
55+
"CRinMqvmOknWRAKERI]RBzB_LXGKQe{SUpoN[\\\\gL[`bLMOhvFqDVVMNOdY"
56+
}
57+
>
5058
goprinbjmmjhfserfuqyluxcewpyjihektogc
5159
</c14>
5260
) : (
53-
<c14 c15="H\\\\\\\\GAcTc\\\\lfGMW[yHriCpvW`w]niSIKj\\\\kdgFI">
61+
<c14 c15={"H\\\\\\\\GAcTc\\\\lfGMW[yHriCpvW`w]niSIKj\\\\kdgFI"}>
5462
yejarlvudihqdrdgpvahovggdnmgnueedxpbwbkdvvkdhqwrtoiual
5563
</c14>
5664
)}

0 commit comments

Comments
 (0)