@vyckr/tachyon 1.3.6 → 1.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/runtime/spa-renderer.ts +25 -8
package/package.json
CHANGED
|
@@ -372,17 +372,34 @@ function navigate(pathname: string) {
|
|
|
372
372
|
};
|
|
373
373
|
|
|
374
374
|
if (layoutPath && layoutChanged) {
|
|
375
|
-
|
|
375
|
+
Promise.all([
|
|
376
|
+
import(layoutPath),
|
|
377
|
+
import(pageURL),
|
|
378
|
+
]).then(async ([layoutMod, pageMod]) => {
|
|
376
379
|
currentLayoutPath = layoutPath;
|
|
377
|
-
layoutRender = await
|
|
380
|
+
layoutRender = await layoutMod.default();
|
|
381
|
+
|
|
382
|
+
if (location.pathname !== pathname) history.pushState({}, '', pathname);
|
|
383
|
+
else history.replaceState({}, '', pathname);
|
|
384
|
+
pageRender = await pageMod.default();
|
|
385
|
+
|
|
378
386
|
freshNavigation = true;
|
|
379
387
|
previousHTML = '';
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
await
|
|
388
|
+
lazyLoaded.clear();
|
|
389
|
+
lazyRenders.clear();
|
|
390
|
+
|
|
391
|
+
// Render layout and page content in one DOM write to eliminate CLS
|
|
392
|
+
const layoutHTML = await layoutRender!();
|
|
393
|
+
const pageHTML = await pageRender();
|
|
394
|
+
previousHTML = pageHTML;
|
|
395
|
+
|
|
396
|
+
const tempDoc = parser.parseFromString(`<body>${layoutHTML}</body>`, 'text/html');
|
|
397
|
+
const slot = tempDoc.getElementById('ty-layout-slot');
|
|
398
|
+
if (slot) slot.innerHTML = pageHTML;
|
|
399
|
+
document.body.innerHTML = tempDoc.body.innerHTML;
|
|
400
|
+
|
|
401
|
+
postPatch();
|
|
402
|
+
freshNavigation = false;
|
|
386
403
|
});
|
|
387
404
|
} else if (!layoutPath && currentLayoutPath) {
|
|
388
405
|
// Leaving a layout
|