Skip to content

Commit 95c2f73

Browse files
committed
Fixed an unhandled promise.
1 parent bcb4436 commit 95c2f73

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capture-template",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "This library is responsible for expanding a template web page and then capturing it PNG or PDF.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

src/web-page-renderer.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,21 @@ export class WebPageRenderer implements IWebPageRenderer {
202202
.then((bodySize: any) => {
203203
return this.nightmare.viewport(bodySize.width, bodySize.height)
204204
})
205-
this.nightmare.evaluate(
206-
(captureSelector: string) => {
207-
const element = document.querySelector(captureSelector);
208-
const rect = element.getBoundingClientRect();
209-
return {
210-
x: Math.ceil(rect.left),
211-
y: Math.ceil(rect.top),
212-
height: Math.ceil(rect.bottom - rect.top),
213-
width: Math.ceil(rect.right - rect.left),
214-
};
215-
},
216-
options.captureSelector || options.waitSelector,
217-
)
205+
.then(() => {
206+
return this.nightmare.evaluate(
207+
(captureSelector: string) => {
208+
const element = document.querySelector(captureSelector);
209+
const rect = element.getBoundingClientRect();
210+
return {
211+
x: Math.ceil(rect.left),
212+
y: Math.ceil(rect.top),
213+
height: Math.ceil(rect.bottom - rect.top),
214+
width: Math.ceil(rect.right - rect.left),
215+
};
216+
},
217+
options.captureSelector || options.waitSelector,
218+
)
219+
})
218220
.then((rect: any) => {
219221
return this.nightmare.screenshot(outputFilePath, rect);
220222
});

0 commit comments

Comments
 (0)