This PR fixes an issue which would lead to content being escaped twice when Fragments with single children were used.
function Foo(props) {
return <>{props.children}</>
}
const nodes = <>{'"test"'}</>
const final = <Foo>{nodes}</Foo>
// Would be transpiled to something like this
function Foo(props) {
return jsxEscape(props.children)
}
const nodes = jsxEscape('"test"')
const final = jsx(Foo, { children: nodes })
The issue occurred because of an incorrect assumption that we could optimize single string or expression child Fragments away to a string. But when the string is passed around we don't know whether the string has already been escaped or not, so the string will be escaped again.
The solution is to drop that faulty optimization and always materialize a container element.
This PR fixes an issue which would lead to content being escaped twice when
Fragments
with single children were used.The issue occurred because of an incorrect assumption that we could optimize single string or expression child Fragments away to a string. But when the string is passed around we don't know whether the string has already been escaped or not, so the string will be escaped again.
The solution is to drop that faulty optimization and always materialize a container element.
Fixes https://github.com/denoland/deno/issues/22965#issuecomment-2024730199