Commit b012c38
committed
fix: inject DSD with inline styles for nested custom elements
The SSR pipeline's injectDSD() was not recursively processing custom
elements nested inside other components' shadow DOM. A <theme-toggle>
inside <blog-shell>'s render output was emitted as an empty element
with no DSD template — no styles, no content until JS upgraded it.
This caused a visible layout shift (CLS) in the header.
Changes:
- render-server.js: recursively call injectDSD() on each component's
rendered inner HTML so nested elements get their own DSD templates
with inline <style> tags. Mirrors how Lit SSR handles this.
- component.js: when a shadow root already exists from DSD, remove
the SSR inline <style> before calling adoptStyles() to avoid
duplicate styles (adoptedStyleSheets takes over).
- blog-shell.ts: revert the manual CLS workaround — no longer needed
since the framework now handles it.1 parent 606e980 commit b012c38
3 files changed
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | 64 | | |
73 | 65 | | |
74 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| 353 | + | |
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
359 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
360 | 370 | | |
361 | 371 | | |
362 | 372 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
| |||
0 commit comments