[2.0 rc.17] A lone spread runs before the element's hydration key on the server, after it on the client
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 58/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- frontend, full-stack
Direzione di ricerca
Start by tracing how the compiler emits server output for a JSX element with a lone spread, then compare it with the client output described in the issue. Check the ssrElement hydration-key allocation and the existing spread compilation tests. Done when a lone spread runs after the server element's hydration key and the reported hydration mismatch is covered by a regression test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Take an element whose only attribute is a spread: <label {...props()} />. The server compiles it to ssrElement(tag, props(), children, true), so props() is an argument and runs before ssrElement allocates the element's hydration key. The client compiles the same element to getNextElement(tmpl) and then spread(el, () => props()), so it claims the key first and runs props() afterwards.
If props() creates an owner (a memo, for example), the server gives that owner the id the element should get. The element's key then shifts by one, on the server only. The client misses the key, creates a detached element, and leaves the server node unclaimed and inert.
When the element has any other attribute, the server wraps the spread in a thunk (ssrElement(tag, [{...}, () => props()], ...)), runs it after the key, and the two sides agree.
Compiled output (@solidjs/vite-plugin 3.0.0-next.51, { ssr: true }):
// server: <label {...composeProps(row, () => ({ class: "x" }))} />
(row) => ssrElement("label", composeProps(row, () => ({ class: "x" })), undefined, true)
// client
var _el$ = _$getNextElement(_tmpl$);
_$spread(_el$, () => composeProps(row, () => ({ class: "x" })), false, undefined, "label")
ssrElement takes the key inside the call (const hk = needsId ? ssrHydrationKey() : ""), after its arguments have been evaluated.
Your Example Website or App
Minimal repro below (no libraries).
Steps to Reproduce the Bug or Issue
// app.tsx: server-render with renderToString + generateHydrationScript, then hydrate(() => <App />, root)
import { createMemo, Show } from "solid-js";
// Creates an owner (a memo) while computing the spread.
const withMemo = () => {
const title = createMemo(() => "spread");
return { get title() { return title(); } };
};
export function App() {
return (
<main>
<Show when={true}>
<label {...withMemo()}>lone spread</label>
</Show>
<Show when={true}>
<label data-x="" {...withMemo()}>spread plus attribute</label>
</Show>
</main>
);
}
Console on hydrate (dev):
Hydration key miss for "30": no server-rendered element carries this key (template: <label>lone spread). A detached element was created instead; ...
Hydration completed with 1 unclaimed server-rendered node(s):
<label _hk="31" title="spread">lone spread</label>
The second label (spread plus an attribute) hydrates.
Expected behavior
A lone spread is evaluated after the element's hydration key on the server, as it is on the client and as a spread next to other attributes already is. For example, emit ssrElement(tag, () => props(), ...), or take the key before evaluating the props.
Platform
- solid-js / @solidjs/web 2.0.0-rc.17
- @solidjs/vite-plugin 3.0.0-next.51 (@solidjs/compiler, @solidjs/babel-plugin 2.0.0-rc.17)
- Chromium (Playwright), Node 26
Additional context
We hit this in a component library, where a styled Switch renders <label {...composeProps(row, () => attrs)} /> and each accessor source becomes a memo. We worked around it by making those memos transparent: true. Related but different: #4081 (ref dropped on a spread element).
- Lingua principale
- TypeScript
- Stelle
- 36.2k
- Fork
- 1.1k
- Merge medio
- 11h
- PR unite (30g)
- 343
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14Forse già presa @itisrmk l’ha presa 7 giorni fa. Aperta1.x
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list itemsForse già presa @boombang l’ha presa 9 giorni fa. Aperta1.x
Difficoltà 4/5 1-2 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
awesome-dsh-plugin/awesome-dsh-plugin#9184 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
farion1231/cc-switch#8829 ·
I maintainer di solito rispondono entro 1 giorno
-
[core-client] Remove unused hand-maintained transport helpers after the definition-table cutoverApertadoc-audit enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100