-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler][repro] JSX escape sequences not printed correctly by @babe…
…l/generator Repro for #32123 Note that this is only a bug when calling `@babel/generator:generate()` before transforming JSX.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...ompiler/src/__tests__/fixtures/compiler/jsx-preserve-escape-character.expect.md
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,57 @@ | ||
|
||
## Input | ||
|
||
```javascript | ||
/** | ||
* Fixture showing `@babel/generator` bug with jsx attribute strings containing | ||
* escape sequences. Note that this is only a problem when generating jsx | ||
* literals. | ||
* | ||
* When using the jsx transform to correctly lower jsx into | ||
* `React.createElement` calls, the escape sequences are preserved correctly | ||
* (see evaluator output). | ||
*/ | ||
function MyApp() { | ||
return <input pattern="\w" />; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: MyApp, | ||
params: [], | ||
}; | ||
|
||
``` | ||
|
||
## Code | ||
|
||
```javascript | ||
import { c as _c } from "react/compiler-runtime"; /** | ||
* Fixture showing `@babel/generator` bug with jsx attribute strings containing | ||
* escape sequences. Note that this is only a problem when generating jsx | ||
* literals. | ||
* | ||
* When using the jsx transform to correctly lower jsx into | ||
* `React.createElement` calls, the escape sequences are preserved correctly | ||
* (see evaluator output). | ||
*/ | ||
function MyApp() { | ||
const $ = _c(1); | ||
let t0; | ||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) { | ||
t0 = <input pattern="\\w" />; | ||
$[0] = t0; | ||
} else { | ||
t0 = $[0]; | ||
} | ||
return t0; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: MyApp, | ||
params: [], | ||
}; | ||
|
||
``` | ||
### Eval output | ||
(kind: ok) <input pattern="\w"> |
17 changes: 17 additions & 0 deletions
17
...el-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-preserve-escape-character.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,17 @@ | ||
/** | ||
* Fixture showing `@babel/generator` bug with jsx attribute strings containing | ||
* escape sequences. Note that this is only a problem when generating jsx | ||
* literals. | ||
* | ||
* When using the jsx transform to correctly lower jsx into | ||
* `React.createElement` calls, the escape sequences are preserved correctly | ||
* (see evaluator output). | ||
*/ | ||
function MyApp() { | ||
return <input pattern="\w" />; | ||
} | ||
|
||
export const FIXTURE_ENTRYPOINT = { | ||
fn: MyApp, | ||
params: [], | ||
}; |