Skip to content

Commit

Permalink
fix: allow lazy/pending hydration after browser has finished loading (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Jun 14, 2024
1 parent 2ccd992 commit 2cf464f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-lamps-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"marko": patch
---

Allow registering/loading top level hydrated components _after_ the "load" event. Previously after the load event it was assumed all assets would have been loaded but this is not always accurate for assets loaded through interactions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ function register(type, def) {
function addPendingDef(def, type, meta, host, runtimeId) {
if (!pendingDefs) {
pendingDefs = {};

// eslint-disable-next-line no-constant-condition
if ("MARKO_DEBUG") {
document.addEventListener("load", function () {
var pendingComponentIds = Object.keys(pendingDefs);
if (pendingComponentIds.length) {
complain(
"Marko templates were never loaded for: " + pendingComponentIds
);
}
});
}
}
(pendingDefs[type] = pendingDefs[type] || []).push([
def,
Expand Down Expand Up @@ -499,7 +487,6 @@ function initServerRendered(renderedComponents, host) {
var typeName = meta.___types[componentDef[1]];

return registered[typeName] ||
document.readyState === "complete" ||
req.e(typeName)
? tryHydrateComponent(componentDef, meta, host, runtimeId)
: addPendingDef(componentDef, typeName, meta, host, runtimeId);
Expand Down

0 comments on commit 2cf464f

Please sign in to comment.