From 81bf443789e323fd14d41287cde03d1f1c6e8709 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Tue, 21 Feb 2023 12:50:43 -0800 Subject: [PATCH] chore: DRY up mouse.click() (#9725) --- packages/puppeteer-core/src/common/Input.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/puppeteer-core/src/common/Input.ts b/packages/puppeteer-core/src/common/Input.ts index 12dfb5d02ad..67e97020e41 100644 --- a/packages/puppeteer-core/src/common/Input.ts +++ b/packages/puppeteer-core/src/common/Input.ts @@ -478,18 +478,14 @@ export class Mouse { options: MouseOptions & {delay?: number} = {} ): Promise { const {delay = null} = options; + await this.move(x, y); + await this.down(options); if (delay !== null) { - await this.move(x, y); - await this.down(options); await new Promise(f => { return setTimeout(f, delay); }); - await this.up(options); - } else { - await this.move(x, y); - await this.down(options); - await this.up(options); } + await this.up(options); } /**