You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ec37f1c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(web): ssrElement accepts an array of prop sources and a skip predicate
`ssrElement(tag, [a, b, c], children, needsId, skip)` serializes straight
from the sources with the exact output of `ssrElement(tag, merge(a, b, c),
...)`: later sources win per key, attributes land in merged order, only the
winning source's getter is read (once), and `skip(key)` drops a key from
every source without reading it. Libraries and compilers spreading several
sources onto an element no longer build an intermediate merged object that
is walked once and discarded.
The array — or a thunk yielding it — is resolved after the hydration key is
taken, so a source getter that renders a child cannot shift the element's
own id. A function source is a plain thunk called once: no memo, no
hydration ids, matching the client `spread` array form. Nullish sources are
empty. The single-object and thunk forms are unchanged.
Measured on the yak-bench SSR suite with next-yak's runtime calling this
instead of its hand-written serializer: elements with dynamic props go
from 2.1-2.9x slower than the hand-written path to 1.1-1.2x; suite geomean
2.43x -> 1.69x.
Co-authored-by: Cursor <[email protected]>
`ssrElement` accepts an array of prop sources and an optional `skip` predicate: `ssrElement(tag, [a, b, c], children, needsId, skip)`. The array form serializes straight from the sources with the exact output of `ssrElement(tag, merge(a, b, c), ...)` — later sources win per key, attributes land in merged order, only the winning source's getter is read (once), and `skip(key)` drops a key from every source without reading it — so libraries and compilers spreading several sources no longer have to build an intermediate merged object that is walked once and discarded. The array (or a thunk yielding it) is resolved after the hydration key is taken; a function source is a plain thunk called once that creates no memo and consumes no hydration ids. Nullish sources are empty. The single-object form is unchanged.
0 commit comments