mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
docs(new): migrate JSHandle docs to TSDoc (#6102)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
## JSHandle class
|
||||
|
||||
Represents an in-page JavaScript object. JSHandles can be created with the [page.evaluateHandle](./puppeteer.page.evaluatehandle.md) method.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
@@ -11,6 +12,17 @@
|
||||
export declare class JSHandle
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
|
||||
```js
|
||||
const windowHandle = await page.evaluateHandle(() => window);
|
||||
|
||||
```
|
||||
JSHandle prevents the referenced JavaScript object from being garbage-collected unless the handle is [disposed](./puppeteer.jshandle.dispose.md)<!-- -->. JSHandles are auto- disposed when their origin frame gets navigated or the parent context gets destroyed.
|
||||
|
||||
JSHandle instances can be used as arguments for [Page.$eval()](./puppeteer.page._eval.md)<!-- -->, [Page.evaluate()](./puppeteer.page.evaluate.md)<!-- -->, and [Page.evaluateHandle()](./puppeteer.page.evaluatehandle.md)<!-- -->.
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
@@ -30,13 +42,13 @@ export declare class JSHandle
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [asElement()](./puppeteer.jshandle.aselement.md) | | |
|
||||
| [dispose()](./puppeteer.jshandle.dispose.md) | | The method stops referencing the element handle. |
|
||||
| [asElement()](./puppeteer.jshandle.aselement.md) | | Returns either <code>null</code> or the object handle itself, if the object handle is an instance of [ElementHandle](./puppeteer.elementhandle.md)<!-- -->. |
|
||||
| [dispose()](./puppeteer.jshandle.dispose.md) | | Stops referencing the element handle, and resolves when the object handle is successfully disposed of. |
|
||||
| [evaluate(pageFunction, args)](./puppeteer.jshandle.evaluate.md) | | This method passes this handle as the first argument to <code>pageFunction</code>. If <code>pageFunction</code> returns a Promise, then <code>handle.evaluate</code> would wait for the promise to resolve and return its value. |
|
||||
| [evaluateHandle(pageFunction, args)](./puppeteer.jshandle.evaluatehandle.md) | | This method passes this handle as the first argument to <code>pageFunction</code>. |
|
||||
| [executionContext()](./puppeteer.jshandle.executioncontext.md) | | |
|
||||
| [executionContext()](./puppeteer.jshandle.executioncontext.md) | | Returns the execution context the handle belongs to. |
|
||||
| [getProperties()](./puppeteer.jshandle.getproperties.md) | | The method returns a map with property names as keys and JSHandle instances for the property values. |
|
||||
| [getProperty(propertyName)](./puppeteer.jshandle.getproperty.md) | | |
|
||||
| [getProperty(propertyName)](./puppeteer.jshandle.getproperty.md) | | Fetches a single property from the referenced object. |
|
||||
| [jsonValue()](./puppeteer.jshandle.jsonvalue.md) | | Returns a JSON representation of the object. |
|
||||
| [toString()](./puppeteer.jshandle.tostring.md) | | |
|
||||
| [toString()](./puppeteer.jshandle.tostring.md) | | Returns a string representation of the JSHandle. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user