mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
6f2fe1e7e9
Nice find, @mofeiZ! I really tried to thoroughly test all the examples I could think of for FBT whitespace but i missed the newline case. Initially Mofei found [this code potentially related to whitespace handling](https://github.com/facebook/fbt/blob/main/packages/babel-plugin-fbt/src/fbt-nodes/FbtImplicitParamNode.js#L230-L233) but Babel never seems to produce consecutive JsxText nodes — this looks like maybe a leftover from older babel versions. I noticed that code wasn't actually trimming the whitspace but clearly it was happening somewhere, so i grepped for 'trim' and found that [this code](https://github.com/facebook/fbt/blob/0b4e0d13c30bffd0daa2a75715d606e3587b4e40/packages/babel-plugin-fbt/src/babel-processors/JSXFbtProcessor.js#L143) calls a [normalizeSpaces](https://github.com/facebook/fbt/blob/0b4e0d13c30bffd0daa2a75715d606e3587b4e40/packages/babel-plugin-fbt/src/FbtUtil.js#L86C10-L86C45) helper. Updating our logic to handle whitespace similarly just for children of fbt nodes produces the expected result.