Skip to content

Commit

Permalink
chore: refactor FrameManager and fix docs (#8770)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Aug 10, 2022
1 parent 2580347 commit d6a88a9
Show file tree
Hide file tree
Showing 67 changed files with 1,254 additions and 1,197 deletions.
2 changes: 1 addition & 1 deletion docs/api/index.md
Expand Up @@ -39,7 +39,7 @@ sidebar_label: API
| [TimeoutError](./puppeteer.timeouterror.md) | TimeoutError is emitted whenever certain operations are terminated due to timeout. |
| [Touchscreen](./puppeteer.touchscreen.md) | The Touchscreen class exposes touchscreen events. |
| [Tracing](./puppeteer.tracing.md) | The Tracing class exposes the tracing audit interface. |
| [WebWorker](./puppeteer.webworker.md) | The WebWorker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). |
| [WebWorker](./puppeteer.webworker.md) | This class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). |

## Enumerations

Expand Down
14 changes: 5 additions & 9 deletions docs/api/puppeteer.elementhandle._.md
Expand Up @@ -4,7 +4,7 @@ sidebar_label: ElementHandle.$

# ElementHandle.$() method

Runs `element.querySelector` within the page.
Queries the current element for an element matching the given selector.

**Signature:**

Expand All @@ -18,16 +18,12 @@ class ElementHandle {

## Parameters

| Parameter | Type | Description |
| --------- | -------- | --------------------------- |
| selector | Selector | The selector to query with. |
| Parameter | Type | Description |
| --------- | -------- | -------------------------- |
| selector | Selector | The selector to query for. |

**Returns:**

Promise<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>> \| null>

`null` if no element matches the selector.

## Exceptions

`Error` if the selector has no associated query handler.
A [element handle](./puppeteer.elementhandle.md) to the first element matching the given selector. Otherwise, `null`.
14 changes: 5 additions & 9 deletions docs/api/puppeteer.elementhandle.__.md
Expand Up @@ -4,7 +4,7 @@ sidebar_label: ElementHandle.$$

# ElementHandle.$$() method

Runs `element.querySelectorAll` within the page.
Queries the current element for all elements matching the given selector.

**Signature:**

Expand All @@ -18,16 +18,12 @@ class ElementHandle {

## Parameters

| Parameter | Type | Description |
| --------- | -------- | --------------------------- |
| selector | Selector | The selector to query with. |
| Parameter | Type | Description |
| --------- | -------- | -------------------------- |
| selector | Selector | The selector to query for. |

**Returns:**

Promise<Array<[ElementHandle](./puppeteer.elementhandle.md)<[NodeFor](./puppeteer.nodefor.md)<Selector>>>>

`[]` if no element matches the selector.

## Exceptions

`Error` if the selector has no associated query handler.
An array of [element handles](./puppeteer.elementhandle.md) that point to elements matching the given selector.
24 changes: 14 additions & 10 deletions docs/api/puppeteer.elementhandle.__eval.md
Expand Up @@ -4,9 +4,9 @@ sidebar_label: ElementHandle.$$eval

# ElementHandle.$$eval() method

This method runs `document.querySelectorAll` within the element and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
Runs the given function on an array of elements matching the given selector in the current element.

If `pageFunction` returns a Promise, then `frame.$$eval` would wait for the promise to resolve and return its value.
If the given function returns a promise, then this method will wait till the promise resolves.

**Signature:**

Expand All @@ -28,17 +28,21 @@ class ElementHandle {

## Parameters

| Parameter | Type | Description |
| ------------ | -------------- | ----------- |
| selector | Selector | |
| pageFunction | Func \| string | |
| args | Params | |
| Parameter | Type | Description |
| ------------ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| selector | Selector | The selector to query for. |
| pageFunction | Func \| string | The function to be evaluated in the element's page's context. An array of elements matching the given selector will be passed to the function as its first argument. |
| args | Params | Additional arguments to pass to <code>pageFunction</code>. |

**Returns:**

Promise&lt;Awaited&lt;ReturnType&lt;Func&gt;&gt;&gt;

## Example 1
A promise to the result of the function.

## Example

HTML:

```html
<div class="feed">
Expand All @@ -47,9 +51,9 @@ Promise&lt;Awaited&lt;ReturnType&lt;Func&gt;&gt;&gt;
</div>
```

## Example 2
JavaScript:

```ts
```js
const feedHandle = await page.$('.feed');
expect(
await feedHandle.$$eval('.tweet', nodes => nodes.map(n => n.innerText))
Expand Down
16 changes: 9 additions & 7 deletions docs/api/puppeteer.elementhandle._eval.md
Expand Up @@ -4,9 +4,9 @@ sidebar_label: ElementHandle.$eval

# ElementHandle.$eval() method

This method runs `document.querySelector` within the element and passes it as the first argument to `pageFunction`. If there's no element matching `selector`, the method throws an error.
Runs the given function on the first element matching the given selector in the current element.

If `pageFunction` returns a Promise, then `frame.$eval` would wait for the promise to resolve and return its value.
If the given function returns a promise, then this method will wait till the promise resolves.

**Signature:**

Expand All @@ -28,16 +28,18 @@ class ElementHandle {

## Parameters

| Parameter | Type | Description |
| ------------ | -------------- | ----------- |
| selector | Selector | |
| pageFunction | Func \| string | |
| args | Params | |
| Parameter | Type | Description |
| ------------ | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| selector | Selector | The selector to query for. |
| pageFunction | Func \| string | The function to be evaluated in this element's page's context. The first element matching the selector will be passed in as the first argument. |
| args | Params | Additional arguments to pass to <code>pageFunction</code>. |

**Returns:**

Promise&lt;Awaited&lt;ReturnType&lt;Func&gt;&gt;&gt;

A promise to the result of the function.

## Example

```ts
Expand Down

0 comments on commit d6a88a9

Please sign in to comment.