Commit e8e4383
committed
feat(core): client hydrates data-webjs-prop-* attributes, then strips
Completes the SSR property-binding round-trip. The server emits
data-webjs-prop-<kebab>="<wire-encoded>" for each .prop=${val}
hole in PR-WIP commit 2c4c98e. This commit teaches WebComponent
to consume those attributes on the browser side.
At the top of connectedCallback (before lazy-hydration gating
and before _activate), the component scans its own attributes
for the data-webjs-prop- prefix. For each:
* decode via the same wire serializer used on the server (rich
types like Date, Map, Set, BigInt, cycles)
* assign to the camelCase property (so the reactive accessor
picks it up and triggers normal change-detection)
* removeAttribute() so the settled DOM has no framework cruft
One-time per element via a __webjsPropsHydrated guard, so
disconnect/reconnect cycles do not retry decode on attributes
that no longer exist. Malformed payloads warn once and are
skipped; the rest of the component continues to hydrate.
Net result for the user: writing .posts=${posts} in a parent
template just works through SSR, including on the first paint.
The DOM after hydration completes shows <post-list> with no
extra attributes.1 parent 2c4c98e commit e8e4383
1 file changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
314 | 315 | | |
315 | 316 | | |
316 | 317 | | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
317 | 331 | | |
318 | 332 | | |
319 | 333 | | |
| |||
357 | 371 | | |
358 | 372 | | |
359 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
360 | 407 | | |
361 | 408 | | |
362 | 409 | | |
| |||
0 commit comments