From 5ff205dc8b659eb8864b4b1862105d21dd334c8f Mon Sep 17 00:00:00 2001 From: jrandolf <101637635+jrandolf@users.noreply.github.com> Date: Wed, 6 Jul 2022 09:05:37 +0200 Subject: [PATCH] fix: extends `ElementHandle` to `Node`s (#8552) * fix: extends `ElementHandle` to `Node`s (#8552) --- .eslintignore | 39 +++- .eslintrc.js | 2 + .gitignore | 1 + .prettierignore | 7 +- docs/api/index.md | 1 + docs/api/puppeteer.customqueryhandler.md | 8 +- .../puppeteer.customqueryhandler.queryall.md | 5 +- .../puppeteer.customqueryhandler.queryone.md | 2 +- docs/api/puppeteer.elementhandle._.md | 6 +- docs/api/puppeteer.elementhandle.__.md | 6 +- docs/api/puppeteer.elementhandle.__1.md | 23 --- docs/api/puppeteer.elementhandle.___1.md | 23 --- docs/api/puppeteer.elementhandle.__eval.md | 6 +- docs/api/puppeteer.elementhandle.__eval_1.md | 34 ---- docs/api/puppeteer.elementhandle._eval.md | 6 +- docs/api/puppeteer.elementhandle._eval_1.md | 34 ---- docs/api/puppeteer.elementhandle._x.md | 4 +- docs/api/puppeteer.elementhandle.click.md | 9 +- docs/api/puppeteer.elementhandle.drag.md | 12 +- .../puppeteer.elementhandle.draganddrop.md | 12 +- docs/api/puppeteer.elementhandle.dragenter.md | 12 +- docs/api/puppeteer.elementhandle.dragover.md | 12 +- docs/api/puppeteer.elementhandle.drop.md | 12 +- docs/api/puppeteer.elementhandle.hover.md | 8 +- ...er.elementhandle.isintersectingviewport.md | 14 +- docs/api/puppeteer.elementhandle.md | 69 +++---- .../api/puppeteer.elementhandle.screenshot.md | 12 +- docs/api/puppeteer.elementhandle.tap.md | 8 +- ...puppeteer.elementhandle.waitforselector.md | 6 +- ...ppeteer.elementhandle.waitforselector_1.md | 27 --- .../puppeteer.elementhandle.waitforxpath.md | 4 +- docs/api/puppeteer.frame._.md | 6 +- docs/api/puppeteer.frame.__.md | 6 +- docs/api/puppeteer.frame.__1.md | 23 --- docs/api/puppeteer.frame.___1.md | 23 --- docs/api/puppeteer.frame.__eval.md | 6 +- docs/api/puppeteer.frame.__eval_1.md | 34 ---- docs/api/puppeteer.frame._eval.md | 6 +- docs/api/puppeteer.frame._eval_1.md | 34 ---- docs/api/puppeteer.frame._x.md | 4 +- docs/api/puppeteer.frame.addscripttag.md | 6 +- docs/api/puppeteer.frame.addstyletag.md | 4 +- docs/api/puppeteer.frame.md | 5 - docs/api/puppeteer.frame.waitforselector.md | 6 +- docs/api/puppeteer.frame.waitforselector_1.md | 27 --- docs/api/puppeteer.frame.waitfortimeout.md | 2 +- docs/api/puppeteer.frame.waitforxpath.md | 6 +- docs/api/puppeteer.handlefor.md | 2 +- .../puppeteer.jshandle.___jshandlesymbol_.md | 15 ++ docs/api/puppeteer.jshandle.aselement.md | 4 +- docs/api/puppeteer.jshandle.md | 8 +- docs/api/puppeteer.nodefor.md | 16 ++ docs/api/puppeteer.page._.md | 6 +- docs/api/puppeteer.page.__.md | 8 +- docs/api/puppeteer.page.__1.md | 23 --- docs/api/puppeteer.page.___1.md | 23 --- docs/api/puppeteer.page.__eval.md | 6 +- docs/api/puppeteer.page.__eval_1.md | 34 ---- docs/api/puppeteer.page._eval.md | 6 +- docs/api/puppeteer.page._eval_1.md | 34 ---- docs/api/puppeteer.page._x.md | 4 +- docs/api/puppeteer.page.addscripttag.md | 4 +- docs/api/puppeteer.page.addstyletag.md | 4 +- docs/api/puppeteer.page.md | 5 - docs/api/puppeteer.page.waitforselector.md | 6 +- docs/api/puppeteer.page.waitforselector_1.md | 27 --- docs/api/puppeteer.page.waitfortimeout.md | 2 +- docs/api/puppeteer.page.waitforxpath.md | 4 +- docs/api/puppeteer.snapshotoptions.md | 8 +- docs/api/puppeteer.snapshotoptions.root.md | 2 +- docs/api/puppeteer.timeouterror.md | 2 +- docs/api/puppeteer.waitforselectoroptions.md | 12 +- .../puppeteer.waitforselectoroptions.root.md | 2 +- package.json | 2 +- src/common/Accessibility.ts | 2 +- src/common/AriaQueryHandler.ts | 18 +- src/common/DOMWorld.ts | 186 ++++-------------- src/common/ElementHandle.ts | 138 ++++++------- src/common/ExecutionContext.ts | 12 +- src/common/FrameManager.ts | 90 ++------- src/common/JSHandle.ts | 9 +- src/common/Page.ts | 86 ++------ src/common/QueryHandler.ts | 74 ++++--- src/common/types.ts | 13 +- src/common/util.ts | 2 +- test-d/ElementHandle.test-d.ts | 10 +- test-d/JSHandle.test-d.ts | 8 +- test/src/ariaqueryhandler.spec.ts | 42 ++-- test/src/elementhandle.spec.ts | 74 ++++--- test/src/jshandle.spec.ts | 2 +- test/src/queryselector.spec.ts | 28 +-- test/src/utils.ts | 5 +- utils/internal/custom_markdown_documenter.ts | 2 +- 93 files changed, 597 insertions(+), 1095 deletions(-) delete mode 100644 docs/api/puppeteer.elementhandle.__1.md delete mode 100644 docs/api/puppeteer.elementhandle.___1.md delete mode 100644 docs/api/puppeteer.elementhandle.__eval_1.md delete mode 100644 docs/api/puppeteer.elementhandle._eval_1.md delete mode 100644 docs/api/puppeteer.elementhandle.waitforselector_1.md delete mode 100644 docs/api/puppeteer.frame.__1.md delete mode 100644 docs/api/puppeteer.frame.___1.md delete mode 100644 docs/api/puppeteer.frame.__eval_1.md delete mode 100644 docs/api/puppeteer.frame._eval_1.md delete mode 100644 docs/api/puppeteer.frame.waitforselector_1.md create mode 100644 docs/api/puppeteer.jshandle.___jshandlesymbol_.md create mode 100644 docs/api/puppeteer.nodefor.md delete mode 100644 docs/api/puppeteer.page.__1.md delete mode 100644 docs/api/puppeteer.page.___1.md delete mode 100644 docs/api/puppeteer.page.__eval_1.md delete mode 100644 docs/api/puppeteer.page._eval_1.md delete mode 100644 docs/api/puppeteer.page.waitforselector_1.md diff --git a/.eslintignore b/.eslintignore index 92d834da901..bf92b420f3a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,39 @@ -assets/ +## [START] Keep in sync with .gitignore +# Dependencies +node_modules + +# Production build/ -coverage/ -lib +lib/ + +# Generated files tsconfig.tsbuildinfo +puppeteer.api.json +puppeteer*.tgz +yarn.lock +.docusaurus/ +.cache-loader +.local-chromium/ +.local-firefox/ +test/output-*/ +.dev_profile* +coverage/ + +# IDE Artifacts +.vscode + +# Misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* +## [END] Keep in sync with .gitignore + +# ESLint ignores. +assets/ vendor/ diff --git a/.eslintrc.js b/.eslintrc.js index a107d041040..28664f2d3a9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -140,6 +140,8 @@ module.exports = { 'arrow-body-style': ['error', 'always'], // Error if comments do not adhere to `tsdoc`. 'tsdoc/syntax': 2, + // Keeps array types simple only when they are simple for readability. + '@typescript-eslint/array-type': ['error', {default: 'array-simple'}], 'no-unused-vars': 0, '@typescript-eslint/no-unused-vars': [ 'error', diff --git a/.gitignore b/.gitignore index 76f7d2ec0e5..68b127884eb 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ yarn.lock .local-firefox/ test/output-*/ .dev_profile* +coverage/ # IDE Artifacts .vscode diff --git a/.prettierignore b/.prettierignore index a28c3dbd82c..d3d64d2a174 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ -# Keep in sync with .gitignore - +## [START] Keep in sync with .gitignore # Dependencies node_modules @@ -18,6 +17,7 @@ yarn.lock .local-firefox/ test/output-*/ .dev_profile* +coverage/ # IDE Artifacts .vscode @@ -32,6 +32,7 @@ test/output-*/ npm-debug.log* yarn-debug.log* yarn-error.log* +## [END] Keep in sync with .gitignore # Prettier-only ignores. assets/ @@ -41,4 +42,4 @@ package.json test/assets/ vendor/ docs/ -versioned_*/ \ No newline at end of file +versioned_*/ diff --git a/docs/api/index.md b/docs/api/index.md index 11bf9a8aa29..03f904ace7c 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -155,6 +155,7 @@ sidebar_label: API | [KeyInput](./puppeteer.keyinput.md) | All the valid keys that can be passed to functions that take user input, such as [keyboard.press](./puppeteer.keyboard.press.md) | | [LowerCasePaperFormat](./puppeteer.lowercasepaperformat.md) | | | [MouseButton](./puppeteer.mousebutton.md) | | +| [NodeFor](./puppeteer.nodefor.md) | | | [PaperFormat](./puppeteer.paperformat.md) | All the valid paper format types when printing a PDF. | | [Permission](./puppeteer.permission.md) | | | [Platform](./puppeteer.platform.md) | Supported platforms. | diff --git a/docs/api/puppeteer.customqueryhandler.md b/docs/api/puppeteer.customqueryhandler.md index 9a05a75abac..e2420101f77 100644 --- a/docs/api/puppeteer.customqueryhandler.md +++ b/docs/api/puppeteer.customqueryhandler.md @@ -14,7 +14,7 @@ export interface CustomQueryHandler ## Properties -| Property | Modifiers | Type | Description | -| ------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------- | ----------------- | -| [queryAll?](./puppeteer.customqueryhandler.queryall.md) | | (element: Element \| Document, selector: string) => Element\[\] \| NodeListOf<Element> | (Optional) | -| [queryOne?](./puppeteer.customqueryhandler.queryone.md) | | (element: Element \| Document, selector: string) => Element \| null | (Optional) | +| Property | Modifiers | Type | Description | +| ------------------------------------------------------- | --------- | ---------------------------------------------------- | ----------------- | +| [queryAll?](./puppeteer.customqueryhandler.queryall.md) | | (element: Node, selector: string) => Node\[\] | (Optional) | +| [queryOne?](./puppeteer.customqueryhandler.queryone.md) | | (element: Node, selector: string) => Node \| null | (Optional) | diff --git a/docs/api/puppeteer.customqueryhandler.queryall.md b/docs/api/puppeteer.customqueryhandler.queryall.md index df6b06b477f..f6f88e56359 100644 --- a/docs/api/puppeteer.customqueryhandler.queryall.md +++ b/docs/api/puppeteer.customqueryhandler.queryall.md @@ -8,9 +8,6 @@ sidebar_label: CustomQueryHandler.queryAll ```typescript interface CustomQueryHandler { - queryAll?: ( - element: Element | Document, - selector: string - ) => Element[] | NodeListOf; + queryAll?: (element: Node, selector: string) => Node[]; } ``` diff --git a/docs/api/puppeteer.customqueryhandler.queryone.md b/docs/api/puppeteer.customqueryhandler.queryone.md index 3dd2be298a8..b1cdbf4411f 100644 --- a/docs/api/puppeteer.customqueryhandler.queryone.md +++ b/docs/api/puppeteer.customqueryhandler.queryone.md @@ -8,6 +8,6 @@ sidebar_label: CustomQueryHandler.queryOne ```typescript interface CustomQueryHandler { - queryOne?: (element: Element | Document, selector: string) => Element | null; + queryOne?: (element: Node, selector: string) => Node | null; } ``` diff --git a/docs/api/puppeteer.elementhandle._.md b/docs/api/puppeteer.elementhandle._.md index 4ca24f485d4..2d2f3b3ad66 100644 --- a/docs/api/puppeteer.elementhandle._.md +++ b/docs/api/puppeteer.elementhandle._.md @@ -10,9 +10,9 @@ Runs `element.querySelector` within the page. ```typescript class ElementHandle { - $( + $( selector: Selector - ): Promise | null>; + ): Promise> | null>; } ``` @@ -24,7 +24,7 @@ class ElementHandle { **Returns:** -Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLElementTagNameMap\[Selector\]> \| null> +Promise<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>> \| null> `null` if no element matches the selector. diff --git a/docs/api/puppeteer.elementhandle.__.md b/docs/api/puppeteer.elementhandle.__.md index ff433fc23b4..5d18f3cbb3f 100644 --- a/docs/api/puppeteer.elementhandle.__.md +++ b/docs/api/puppeteer.elementhandle.__.md @@ -10,9 +10,9 @@ Runs `element.querySelectorAll` within the page. ```typescript class ElementHandle { - $$( + $$( selector: Selector - ): Promise[]>; + ): Promise>>>; } ``` @@ -24,7 +24,7 @@ class ElementHandle { **Returns:** -Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLElementTagNameMap\[Selector\]>\[\]> +Promise<Array<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>>>> `[]` if no element matches the selector. diff --git a/docs/api/puppeteer.elementhandle.__1.md b/docs/api/puppeteer.elementhandle.__1.md deleted file mode 100644 index 76740ebddca..00000000000 --- a/docs/api/puppeteer.elementhandle.__1.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -sidebar_label: ElementHandle.$_1 ---- - -# ElementHandle.$() method - -**Signature:** - -```typescript -class ElementHandle { - $(selector: string): Promise; -} -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ------ | ----------- | -| selector | string | | - -**Returns:** - -Promise<[ElementHandle](./puppeteer.elementhandle.md) \| null> diff --git a/docs/api/puppeteer.elementhandle.___1.md b/docs/api/puppeteer.elementhandle.___1.md deleted file mode 100644 index 5eb3a8664e2..00000000000 --- a/docs/api/puppeteer.elementhandle.___1.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -sidebar_label: ElementHandle.$$_1 ---- - -# ElementHandle.$$() method - -**Signature:** - -```typescript -class ElementHandle { - $$(selector: string): Promise; -} -``` - -## Parameters - -| Parameter | Type | Description | -| --------- | ------ | ----------- | -| selector | string | | - -**Returns:** - -Promise<[ElementHandle](./puppeteer.elementhandle.md)\[\]> diff --git a/docs/api/puppeteer.elementhandle.__eval.md b/docs/api/puppeteer.elementhandle.__eval.md index c084f8cbf27..837be87b467 100644 --- a/docs/api/puppeteer.elementhandle.__eval.md +++ b/docs/api/puppeteer.elementhandle.__eval.md @@ -13,11 +13,11 @@ If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the prom ```typescript class ElementHandle { $$eval< - Selector extends keyof HTMLElementTagNameMap, + Selector extends string, Params extends unknown[], Func extends EvaluateFunc< - [HTMLElementTagNameMap[Selector][], ...Params] - > = EvaluateFunc<[HTMLElementTagNameMap[Selector][], ...Params]> + [Array>, ...Params] + > = EvaluateFunc<[Array>, ...Params]> >( selector: Selector, pageFunction: Func | string, diff --git a/docs/api/puppeteer.elementhandle.__eval_1.md b/docs/api/puppeteer.elementhandle.__eval_1.md deleted file mode 100644 index 28d155484b4..00000000000 --- a/docs/api/puppeteer.elementhandle.__eval_1.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -sidebar_label: ElementHandle.$$eval_1 ---- - -# ElementHandle.$$eval() method - -**Signature:** - -```typescript -class ElementHandle { - $$eval< - Params extends unknown[], - Func extends EvaluateFunc<[Element[], ...Params]> = EvaluateFunc< - [Element[], ...Params] - > - >( - selector: string, - pageFunction: Func | string, - ...args: Params - ): Promise>>; -} -``` - -## Parameters - -| Parameter | Type | Description | -| ------------ | -------------- | ----------- | -| selector | string | | -| pageFunction | Func \| string | | -| args | Params | | - -**Returns:** - -Promise<Awaited<ReturnType<Func>>> diff --git a/docs/api/puppeteer.elementhandle._eval.md b/docs/api/puppeteer.elementhandle._eval.md index 5f37cd95d8b..f67319183bb 100644 --- a/docs/api/puppeteer.elementhandle._eval.md +++ b/docs/api/puppeteer.elementhandle._eval.md @@ -13,11 +13,11 @@ If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promi ```typescript class ElementHandle { $eval< - Selector extends keyof HTMLElementTagNameMap, + Selector extends string, Params extends unknown[], Func extends EvaluateFunc< - [HTMLElementTagNameMap[Selector], ...Params] - > = EvaluateFunc<[HTMLElementTagNameMap[Selector], ...Params]> + [ElementHandle>, ...Params] + > = EvaluateFunc<[ElementHandle>, ...Params]> >( selector: Selector, pageFunction: Func | string, diff --git a/docs/api/puppeteer.elementhandle._eval_1.md b/docs/api/puppeteer.elementhandle._eval_1.md deleted file mode 100644 index d98ce8e8ad2..00000000000 --- a/docs/api/puppeteer.elementhandle._eval_1.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -sidebar_label: ElementHandle.$eval_1 ---- - -# ElementHandle.$eval() method - -**Signature:** - -```typescript -class ElementHandle { - $eval< - Params extends unknown[], - Func extends EvaluateFunc<[Element, ...Params]> = EvaluateFunc< - [Element, ...Params] - > - >( - selector: string, - pageFunction: Func | string, - ...args: Params - ): Promise>>; -} -``` - -## Parameters - -| Parameter | Type | Description | -| ------------ | -------------- | ----------- | -| selector | string | | -| pageFunction | Func \| string | | -| args | Params | | - -**Returns:** - -Promise<Awaited<ReturnType<Func>>> diff --git a/docs/api/puppeteer.elementhandle._x.md b/docs/api/puppeteer.elementhandle._x.md index 038dfda49b8..d1756a75f00 100644 --- a/docs/api/puppeteer.elementhandle._x.md +++ b/docs/api/puppeteer.elementhandle._x.md @@ -10,7 +10,7 @@ The method evaluates the XPath expression relative to the elementHandle. If ther ```typescript class ElementHandle { - $x(expression: string): Promise; + $x(expression: string): Promise>>; } ``` @@ -22,4 +22,4 @@ class ElementHandle { **Returns:** -Promise<[ElementHandle](./puppeteer.elementhandle.md)\[\]> +Promise<Array<[ElementHandle](./puppeteer.elementhandle.md)<Node>>> diff --git a/docs/api/puppeteer.elementhandle.click.md b/docs/api/puppeteer.elementhandle.click.md index 3ee7e6d1a7d..820e44285be 100644 --- a/docs/api/puppeteer.elementhandle.click.md +++ b/docs/api/puppeteer.elementhandle.click.md @@ -10,15 +10,16 @@ This method scrolls element into view if needed, and then uses [Page.mouse](./pu ```typescript class ElementHandle { - click(options?: ClickOptions): Promise; + click(this: ElementHandle, options?: ClickOptions): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ------------------------------------------- | ----------------- | -| options | [ClickOptions](./puppeteer.clickoptions.md) | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| options | [ClickOptions](./puppeteer.clickoptions.md) | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.drag.md b/docs/api/puppeteer.elementhandle.drag.md index e70a02719d0..b0ddb62cd41 100644 --- a/docs/api/puppeteer.elementhandle.drag.md +++ b/docs/api/puppeteer.elementhandle.drag.md @@ -10,15 +10,19 @@ This method creates and captures a dragevent from the element. ```typescript class ElementHandle { - drag(target: Point): Promise; + drag( + this: ElementHandle, + target: Point + ): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------------- | ----------- | -| target | [Point](./puppeteer.point.md) | | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| target | [Point](./puppeteer.point.md) | | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.draganddrop.md b/docs/api/puppeteer.elementhandle.draganddrop.md index aaff3f87e60..efec7602aed 100644 --- a/docs/api/puppeteer.elementhandle.draganddrop.md +++ b/docs/api/puppeteer.elementhandle.draganddrop.md @@ -11,7 +11,8 @@ This method triggers a dragenter, dragover, and drop on the element. ```typescript class ElementHandle { dragAndDrop( - target: ElementHandle, + this: ElementHandle, + target: ElementHandle, options?: { delay: number; } @@ -21,10 +22,11 @@ class ElementHandle { ## Parameters -| Parameter | Type | Description | -| --------- | --------------------------------------------- | ----------------- | -| target | [ElementHandle](./puppeteer.elementhandle.md) | | -| options | { delay: number; } | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| target | [ElementHandle](./puppeteer.elementhandle.md)<Node> | | +| options | { delay: number; } | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.dragenter.md b/docs/api/puppeteer.elementhandle.dragenter.md index b30944d758d..2f8f3b82f7e 100644 --- a/docs/api/puppeteer.elementhandle.dragenter.md +++ b/docs/api/puppeteer.elementhandle.dragenter.md @@ -10,15 +10,19 @@ This method creates a `dragenter` event on the element. ```typescript class ElementHandle { - dragEnter(data?: Protocol.Input.DragData): Promise; + dragEnter( + this: ElementHandle, + data?: Protocol.Input.DragData + ): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------- | ----------------- | -| data | Protocol.Input.DragData | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| data | Protocol.Input.DragData | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.dragover.md b/docs/api/puppeteer.elementhandle.dragover.md index 65126653c04..90db5c5cd50 100644 --- a/docs/api/puppeteer.elementhandle.dragover.md +++ b/docs/api/puppeteer.elementhandle.dragover.md @@ -10,15 +10,19 @@ This method creates a `dragover` event on the element. ```typescript class ElementHandle { - dragOver(data?: Protocol.Input.DragData): Promise; + dragOver( + this: ElementHandle, + data?: Protocol.Input.DragData + ): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------- | ----------------- | -| data | Protocol.Input.DragData | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| data | Protocol.Input.DragData | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.drop.md b/docs/api/puppeteer.elementhandle.drop.md index 0d9411b64b6..47d3af82cb1 100644 --- a/docs/api/puppeteer.elementhandle.drop.md +++ b/docs/api/puppeteer.elementhandle.drop.md @@ -10,15 +10,19 @@ This method triggers a drop on the element. ```typescript class ElementHandle { - drop(data?: Protocol.Input.DragData): Promise; + drop( + this: ElementHandle, + data?: Protocol.Input.DragData + ): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------- | ----------------- | -| data | Protocol.Input.DragData | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| data | Protocol.Input.DragData | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.hover.md b/docs/api/puppeteer.elementhandle.hover.md index 70a55430c04..874ed7a7c49 100644 --- a/docs/api/puppeteer.elementhandle.hover.md +++ b/docs/api/puppeteer.elementhandle.hover.md @@ -10,10 +10,16 @@ This method scrolls element into view if needed, and then uses [Page.mouse](./pu ```typescript class ElementHandle { - hover(): Promise; + hover(this: ElementHandle): Promise; } ``` +## Parameters + +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | + **Returns:** Promise<void> diff --git a/docs/api/puppeteer.elementhandle.isintersectingviewport.md b/docs/api/puppeteer.elementhandle.isintersectingviewport.md index 6202889192a..4eaafc38fc0 100644 --- a/docs/api/puppeteer.elementhandle.isintersectingviewport.md +++ b/docs/api/puppeteer.elementhandle.isintersectingviewport.md @@ -10,15 +10,21 @@ Resolves to true if the element is visible in the current viewport. ```typescript class ElementHandle { - isIntersectingViewport(options?: {threshold?: number}): Promise; + isIntersectingViewport( + this: ElementHandle, + options?: { + threshold?: number; + } + ): Promise; } ``` ## Parameters -| Parameter | Type | Description | -| --------- | ----------------------- | ----------------- | -| options | { threshold?: number; } | (Optional) | +| Parameter | Type | Description | +| --------- | ------------------------------------------------------------ | ----------------- | +| this | [ElementHandle](./puppeteer.elementhandle.md)<Element> | | +| options | { threshold?: number; } | (Optional) | **Returns:** diff --git a/docs/api/puppeteer.elementhandle.md b/docs/api/puppeteer.elementhandle.md index ae4016079a6..e5a303a30eb 100644 --- a/docs/api/puppeteer.elementhandle.md +++ b/docs/api/puppeteer.elementhandle.md @@ -9,14 +9,14 @@ ElementHandle represents an in-page DOM element. **Signature:** ```typescript -export declare class ElementHandle extends JSHandle +export declare class ElementHandle extends JSHandle ``` **Extends:** [JSHandle](./puppeteer.jshandle.md) ## Remarks -ElementHandles can be created with the method. +ElementHandles can be created with the [Page.$()](./puppeteer.page._.md) method. ```ts const puppeteer = require('puppeteer'); @@ -33,7 +33,7 @@ const puppeteer = require('puppeteer'); ElementHandle prevents the DOM element from being garbage-collected unless the handle is [disposed](./puppeteer.jshandle.dispose.md). ElementHandles are auto-disposed when their origin frame gets navigated. -ElementHandle instances can be used as arguments in and [Page.evaluate()](./puppeteer.page.evaluate.md) methods. +ElementHandle instances can be used as arguments in [Page.$eval()](./puppeteer.page._eval.md) and [Page.evaluate()](./puppeteer.page.evaluate.md) methods. If you're using TypeScript, ElementHandle takes a generic argument that denotes the type of element the handle is holding within. For example, if you have a handle to a `