Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit ea7efc7

Browse files
committed
Use evil hack to wait for html load #43
1 parent 0d3c0b8 commit ea7efc7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/core/nightmare/NightmareService.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ function execute<T>(f: (Nightmare) => Promise<T>): Promise<T> {
1919
export function renderHtmlAsPng(html: string, width: number, height: number): Promise<Buffer> {
2020
return execute(async function(nm) {
2121
nm.viewport(width, height);
22-
nm.goto("about:blank");
23-
await nm.wait(function (html: string){
24-
document.body.innerHTML = html;
25-
return true;
26-
}, html);
22+
nm.goto("data:text/html;charset=utf-8," + html);
23+
await nm.wait(function(){ return true; }); // HTML 전체 로딩까지 대기
2724
let buffer: Buffer = await nm.screenshot();
2825
return buffer;
2926
});

0 commit comments

Comments
 (0)