Commit a04a974
committed
fix: load page component modules on same-layout navigation
Root cause of both bugs: on client-side navigation within the same
layout, the router swapped <main> content but did NOT load the new
page's component modules. Components like <new-post> appeared in the
DOM as plain HTMLElement — never upgraded, no event handlers, no
interactivity.
The fix: call mergeHead() on same-layout swaps (previously skipped
by design). This adds new <link rel="modulepreload"> and executes
new <script type="module"> tags from the target page's <head>,
registering the page's components so they upgrade after insertion.
Also fixed mergeHead to recreate <script> elements instead of
cloning them — cloned scripts don't execute in the browser.1 parent 2d260dc commit a04a974
1 file changed
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
205 | | - | |
206 | | - | |
| 204 | + | |
| 205 | + | |
207 | 206 | | |
208 | 207 | | |
209 | 208 | | |
| |||
345 | 344 | | |
346 | 345 | | |
347 | 346 | | |
348 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
349 | 356 | | |
350 | 357 | | |
351 | 358 | | |
| |||
0 commit comments