Open coravacav opened 3 months ago
Thanks for reporting, this looks like a bug. We'll prioritize a fix.
It seems like this issue existed even before BuildHIR🤔
Thanks for reporting! I have a PR #29997 for preserving the JsxExpressionContainer if it contains non-ascii characters, which fixes the first example in your repro. However the 2nd case is an issue with @babel/parser as @SeekingLight233 pointed out. We could perhaps also check if jsx attribute string literals contain those special characters and convert it into a JsxExpressionContainer
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwAkIBbBACgEp8wADpt8MBLlhteo-PPwAeAHxyF8xQGVuCAMLdsdBHQK4MuALzAA5AEFhogKLWAvvgD0qseq079XQ2NTcwthEHsnMI8vH081fgBuURdREBcgA
Repro steps
\n
) passed as a prop to a component with curly bracesprop={"text\ntext"}
prop="text\ntext"
instead ofprop={"text\ntext"}
This is incorrect behavior. The newline character is no longer properly treated as a newline but rather as the raw text
\n
.You can see this behavior be correctly also incorrectly handled in the second component, where
prop="text\ntext"
becomesprop="text\\ntext"
, resulting in the wrong text being displayed on the screen.JSX rules specifically don't allow this kind of conversion, noted in 1.5.1 of the spec
How often does this bug happen?
Every time
What version of React are you using?
19.0.0-rc-6f23540c7d-20240528