Skip to content

Commit 81ad5e9

Browse files
authored
fix(pupperteerrenderplugn.ts): inject scully content on both timeout and scully-ready event (#246)
closes #239
1 parent a7e967d commit 81ad5e9

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scully/renderPlugins/puppeteerRenderPlugin.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ export const puppeteerRender = async (route: HandledRoute): Promise<string> => {
4141
/** set "running" mode */
4242
window['ScullyIO'] = 'running';
4343
window.addEventListener('AngularReady', () => {
44-
/** add a small script tag to set "generated" mode */
45-
const d = document.createElement('script');
46-
d.innerHTML = `window['ScullyIO']='generated';`;
47-
document.head.appendChild(d);
48-
document.body.setAttribute('scully-version', window['scullyVersion']);
4944
window['onCustomEvent']();
5045
});
5146
});
@@ -54,6 +49,14 @@ export const puppeteerRender = async (route: HandledRoute): Promise<string> => {
5449
await page.goto(path);
5550

5651
await Promise.race([pageReady, waitForIt(25 * 1000)]);
52+
await page.evaluate(() => {
53+
/** add a small script tag to set "generated" mode */
54+
const d = document.createElement('script');
55+
d.innerHTML = `window['ScullyIO']='generated';`;
56+
document.head.appendChild(d);
57+
/** inject the scully version into the body attribute */
58+
document.body.setAttribute('scully-version', window['scullyVersion']);
59+
});
5760

5861
/**
5962
* The stange notation is needed bcs typescript messes

0 commit comments

Comments
 (0)