Skip to content

Commit

Permalink
Use evil hack to wait for html load #43
Browse files Browse the repository at this point in the history
  • Loading branch information
bekker committed Oct 22, 2018
1 parent 0d3c0b8 commit ea7efc7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/core/nightmare/NightmareService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ function execute<T>(f: (Nightmare) => Promise<T>): Promise<T> {
export function renderHtmlAsPng(html: string, width: number, height: number): Promise<Buffer> {
return execute(async function(nm) {
nm.viewport(width, height);
nm.goto("about:blank");
await nm.wait(function (html: string){
document.body.innerHTML = html;
return true;
}, html);
nm.goto("data:text/html;charset=utf-8," + html);
await nm.wait(function(){ return true; }); // HTML 전체 로딩까지 대기
let buffer: Buffer = await nm.screenshot();
return buffer;
});
Expand Down

0 comments on commit ea7efc7

Please sign in to comment.