Repository navigation
Conversation
- Escape string and template literals in a ternary branch, after `&&`, and in a function child's return at compile time in the server build. - `_$ssr` and `_$ssrAttribute` write these values unescaped, so the server rendered markup where the client inserted text. - A function value in an attribute keeps its source, because `_$ssrAttribute` stringifies it. - Apply the same change to the Babel plugin to keep both compilers' output equal. Fixes solidjs#4710 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 78b19f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Merging this PR will improve performance by 16.52%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
|
Thanks for this. The ternary,
Could you carry the attribute exception into the branch recursion and walk nested returns, and add fixtures for a function attribute containing a ternary and for a return inside Generated by Claude Code |
… returns - A function value in an attribute keeps the literals in its ternary and `&&` branches as written. `ssrAttribute` stringifies the function's source and escapes it, so an escape at compile time escaped them twice. - Escape every `return` of a function child or call, including one inside `if`, `switch`, `try`, a loop or a block. Nested functions stay as is. - Replace the `escapeLiterals` flag with three modes (top, escape, keep) in both compilers, so the attribute exception carries through branches. - Add fixtures for both cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, both gaps are fixed in 78b19f4, in the Babel plugin and the Rust compiler.
New fixtures in |
The server build now escapes string literals in a ternary branch, after
&&, and in a function child's return. Before, the server rendered these literals as markup while the client inserted them as text. Fixes #4710.Changes
escape_expression_in_placeinpackages/compiler/src/ssr/transform.rsescapes literals in conditional branches, the right side of&&, and IIFE returns._$ssrAttributestringifies that function's source.`a\nb`keeps its newline.escapeExpressioninpackages/babel-plugin/src/ssr/element.tsgets the same change, so both compilers emit equal output.template78totemplate83in theconditionalExpressionsSSR fixture.Proof
Compiled with
generate: "ssr"and rendered withrenderToStringfrom the workspace builds of@solidjs/webandsolid-js:hydratable: falsehydratable: truenext(81a12d8)<p><b>Open</b></p><p _hk=0><b>Open</b></p><p><b>Open</b></p><p _hk=0><b>Open</b></p>The attribute case had the same gap.
<p title={a() ? '"<b>' : 0} />renderedtitle=""<b>"onnextand renderstitle=""<b>"on this branch.These cases render with one escape on both compilers, so there is no double escape:
{props.children}<Show>child orfallbackstyleChecks
packages/babel-plugin:pnpm testpasses (414 tests).packages/compiler:cargo test,cargo clippy -- -D warningsandvitest runpass. Under load, 4 parity tests timed out. They pass when run alone.packages/web:pnpm testpasses except 2 server specs that time out under load. They pass alone on this branch and onnext.Cost
Risk
Not done
`<b>${x}</b>`, are still written raw on the server.+, such as"<b>" + x, are still written raw on the server.🤖 Generated with Claude Code