Skip to content

Commit

Permalink
Try prerender-trigger event only after body has been updated to make …
Browse files Browse the repository at this point in the history
…sure Elm has rendered.
  • Loading branch information
dillonkearns committed Jan 28, 2020
1 parent b562b02 commit 5de7988
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ function loadContentAndInitializeApp(/** @type { init: any } */ mainElmModule)
headTags.forEach(headTag => {
appendTag(headTag);
});

new MutationObserver(function() {
document.dispatchEvent(new Event("prerender-trigger"));
}).observe(document.body, { attributes: true, childList: true, subtree: true});

} else {
setupLinkPrefetching();
}

document.dispatchEvent(new Event("prerender-trigger"));
});

return app
Expand Down

0 comments on commit 5de7988

Please sign in to comment.