-
Notifications
You must be signed in to change notification settings - Fork 47.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler:codegen] Wrap non-ascii characters in JsxExpressionContainer
This PR extends the previous logic added in #29141 to also account for other kinds of non-ascii characters such as `\n`. Because these control characters are individual special characters (and not 2 characters `\` and `n`) we match based on unicode which was already being checked for non-Latin characters. This allows control characters to continue to be compiled equivalently to its original source if it was provided in a JsxExpressionContainer. However note that this PR does not convert JSX attributes that are StringLiterals to JsxExpressionContainer, to preserve the original source code as it was written. Alternatively we could always emit a JsxExpressionContainer if it was used in the source and not try to down level it to some other node kind. But since we already do this I opted to keep this behavior. Partially addresses #29648. ghstack-source-id: 965cf50df43ff8f8211990223ef1ecb2dfdcfec7 Pull Request resolved: #29997
- Loading branch information
Showing
4 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+1.14 KB
...piler/src/__tests__/fixtures/compiler/jsx-string-attribute-expression-container.expect.md
Binary file not shown.
19 changes: 19 additions & 0 deletions
19
...act-compiler/src/__tests__/fixtures/compiler/jsx-string-attribute-expression-container.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function Component() { | ||
return ( | ||
<div> | ||
<Text value={"\u0000"} /> | ||
<Text value={"A\tE"} /> | ||
<Text value={"나은"} /> | ||
<Text value={"Sathya"} /> | ||
</div> | ||
); | ||
} | ||
|
||
function Text({ value }) { | ||
return <span>{value}</span>; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: Component, | ||
params: [{}], | ||
}; |