[compiler][patch] Fix jsx non-ascii regex pattern
ghstack-source-id: 97ed49112453c2ca3165361e758b6f31fbd0da20 Pull Request resolved: https://github.com/facebook/react/pull/30382
Mofei Zhang committed
Jul 18, 2024 at 15:33 UTC
e15c5b15c67202b30faecf24a66547725cd08480
3 files changed
+45
-9
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts
+1
-1
@@ -2206,7 +2206,7 @@ function codegenInstructionValue(
2206
* https://en.wikipedia.org/wiki/List_of_Unicode_characters#Control_codes
2207
*/
2208
const STRING_REQUIRES_EXPR_CONTAINER_PATTERN =
2209
- /[\u{0000}-\u{001F}|\u{007F}|\u{0080}-\u{FFFF}]|"/u;
2209
+ /[\u{0000}-\u{001F}\u{007F}\u{0080}-\u{FFFF}]|"/u;
2210
function codegenJsxAttribute(
2211
cx: Context,
2212
attribute: JsxAttribute
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-params.expect.md
+36
-5
@@ -6,9 +6,14 @@ import fbt from "fbt";
6
7
function Component(props) {
8
return (
9
- <fbt desc={"Dialog to show to user"}>
10
- Hello <fbt:param name="user name">{props.name}</fbt:param>
11
- </fbt>
9
+ <div>
10
+ <fbt desc={"Dialog to show to user"}>
11
+ Hello <fbt:param name="user name">{props.name}</fbt:param>
12
+ </fbt>
13
+ <fbt desc={"Available actions|response"}>
14
+ <fbt:param name="actions|response">{props.actions}</fbt:param>
15
+ </fbt>
16
+ </div>
17
);
18
}
19
@@ -27,7 +32,7 @@ import { c as _c } from "react/compiler-runtime";
32
import fbt from "fbt";
33
34
function Component(props) {
30
- const $ = _c(2);
35
+ const $ = _c(7);
36
let t0;
37
if ($[0] !== props.name) {
38
t0 = fbt._("Hello {user name}", [fbt._param("user name", props.name)], {
@@ -38,7 +43,33 @@ function Component(props) {
43
} else {
44
t0 = $[1];
45
}
41
- return t0;
46
+ let t1;
47
+ if ($[2] !== props.actions) {
48
+ t1 = fbt._(
49
+ "{actions|response}",
50
+ [fbt._param("actions|response", props.actions)],
51
+ { hk: "1cjfbg" },
52
+ );
53
+ $[2] = props.actions;
54
+ $[3] = t1;
55
+ } else {
56
+ t1 = $[3];
57
+ }
58
+ let t2;
59
+ if ($[4] !== t0 || $[5] !== t1) {
60
+ t2 = (
61
+ <div>
62
+ {t0}
63
+ {t1}
64
+ </div>
65
+ );
66
+ $[4] = t0;
67
+ $[5] = t1;
68
+ $[6] = t2;
69
+ } else {
70
+ t2 = $[6];
71
+ }
72
+ return t2;
73
}
74
75
export const FIXTURE_ENTRYPOINT = {
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/fbt/fbt-params.js
+8
-3
@@ -2,9 +2,14 @@ import fbt from "fbt";
2
3
function Component(props) {
4
return (
5
- <fbt desc={"Dialog to show to user"}>
6
- Hello <fbt:param name="user name">{props.name}</fbt:param>
7
- </fbt>
5
+ <div>
6
+ <fbt desc={"Dialog to show to user"}>
7
+ Hello <fbt:param name="user name">{props.name}</fbt:param>
8
+ </fbt>
9
+ <fbt desc={"Available actions|response"}>
10
+ <fbt:param name="actions|response">{props.actions}</fbt:param>
11
+ </fbt>
12
+ </div>
13
);
14
}
15