fix: avoid structuredClone for Node 16 (#11006)

This commit is contained in:
Alex Rudenko 2023-09-22 22:37:03 +02:00 committed by GitHub
parent c3bd8eb878
commit 25eca9a747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2277,7 +2277,15 @@ export abstract class Page extends EventEmitter<PageEvents> {
): Promise<Buffer | string> {
await this.bringToFront();
const options = structuredClone(userOptions) as ScreenshotOptions;
// TODO: use structuredClone after Node 16 support is dropped.«
const options = {
...userOptions,
clip: userOptions.clip
? {
...userOptions.clip,
}
: undefined,
} as ScreenshotOptions;
if (options.type === undefined && options.path !== undefined) {
const filePath = options.path;
// Note we cannot use Node.js here due to browser compatability.