-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Labels
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
<example>
foo
<hr /> 
bar
</example>;Configuration file name
No response
Configuration
{
"filename": "repl.jsx",
"presets": [
["react", { "runtime": "automatic" }]
]
}Current and expected behavior
Any number of leading or trailing whitespace characters encoded with HTML entities are stripped from JSX. This includes not only (space) but (tab), (newline), and (carriage return). These characters should normally be stripped when unencoded, but when encoded using HTML Entities they should not be stripped, the programmer added them intentionally.
Current Output:
/*#__PURE__*/_jsxs("example", {
children: ["foo", /*#__PURE__*/_jsx("hr", {}), "bar"]
});Expected Output:
/*#__PURE__*/_jsxs("example", {
children: ["foo", /*#__PURE__*/_jsx("hr", {}), " bar"]
});Whitespace created by HTML Entities is preserved.
Environment
REPL
Possible solution
Decoding HTML Entities should be performed after trimming the string, not before.
Additional context
esbuild and tsc preserve these characters when encoded as html entities. swc does not swc-project/swc#11392.
Reactions are currently unavailable