portadom / Exports
- AnyHandle
- BrowserPortadom
- CheerioPortadom
- HandleLike
- PlaywrightHandlePortadom
- PlaywrightLocatorPortadom
- PlaywrightPortapage
- browserPortadom
- cheerioPortadom
- createPlaywrightElementSerializer
- createPortadomArrayPromise
- createPortadomPromise
- handleIsLocator
- mergeHandles
- playwrightHandlePortadom
- playwrightLocatorPortadom
- playwrightPortapage
- splitCheerioSelection
- splitPlaywrightSelection
Ƭ AnyHandle<T
>: JSHandle
<T
> | ElementHandle
<T
>
Any instance that is a Playwright Handle.
Name | Type |
---|---|
T |
any |
Ƭ BrowserPortadom<T
>: Portadom
<T
, Element
>
Implementation of Portadom in browser (using Browser API)
Name | Type |
---|---|
T |
extends Element = Element |
Ƭ CheerioPortadom<El
>: Portadom
<El
, Cheerio
<AnyNode
>>
Implementation of Portadom in Cheerio
Name | Type |
---|---|
El |
extends Cheerio <AnyNode > = Cheerio <AnyNode > |
Ƭ HandleLike<T
>: Locator
| JSHandle
<T
> | ElementHandle
<T
>
Any instance that is a Playwright Handle, or can be converted to one.
Name | Type |
---|---|
T |
any |
Ƭ PlaywrightHandlePortadom<El
>: Portadom
<El
, Locator
| ElementHandle
<Node
>>
Implementation of Portadom in Playwright using Handles
Name | Type |
---|---|
El |
extends Locator | ElementHandle <Node > = Locator | ElementHandle <Node > |
Ƭ PlaywrightLocatorPortadom<El
>: Portadom
<El
, Locator
>
Implementation of Portadom in Playwright using Locators
Name | Type |
---|---|
El |
extends Locator = Locator |
Ƭ PlaywrightPortapage<T
>: Portapage
<T
, PWIST
, { container
: PWIST
["container"
] ; page
: T
}>
Implementation of Portapage in Playwright
Name | Type |
---|---|
T |
extends Page = Page |
▸ browserPortadom<El
>(node
): BrowserPortadom
<El
>
Implementation of Portadom in browser (using Browser API)
Name | Type |
---|---|
El |
extends Element <El > |
Name | Type |
---|---|
node |
El |
BrowserPortadom
<El
>
▸ cheerioPortadom<El
>(cheerioNode
, srcUrl
): CheerioPortadom
<El
>
Implementation of Portadom in Cheerio
Name | Type |
---|---|
El |
extends Cheerio <AnyNode , El > |
Name | Type |
---|---|
cheerioNode |
El |
srcUrl |
null | string |
CheerioPortadom
<El
>
▸ createPlaywrightElementSerializer<T
>(page
): Promise
<{ resolveId
: (id
: string
) => Promise
<JSHandle
<null
> | ElementHandle
<Element
>> ; resolveIds
: (ids
: string
[]) => Promise
<JSHandle
<(null
| Element
)[]>> ; serializeEls
: (elsHandle
: JSHandle
<Element
[]>) => Promise
<string
[]> }>
Helper methods that allow to represent HTML Elements on the Page as string IDs
We use this so we can identify which elements have already been processed, and which have not. Normally, the elements are represented via Playwright JSHandle/ElementHandle. However, if two Handles are pointing to the same Element, we're unable to count them as one, because it's two instances that don't have any IDs of the Elemenets. On the other hand, using the string IDs, two different JSHandles will return the same string if they point to the same Element, so we cache the IDs outside of Playwright in Sets or Maps.
Name | Type |
---|---|
T |
extends Page <T > |
Name | Type |
---|---|
page |
T |
Promise
<{ resolveId
: (id
: string
) => Promise
<JSHandle
<null
> | ElementHandle
<Element
>> ; resolveIds
: (ids
: string
[]) => Promise
<JSHandle
<(null
| Element
)[]>> ; serializeEls
: (elsHandle
: JSHandle
<Element
[]>) => Promise
<string
[]> }>
▸ createPortadomArrayPromise<El
, BaseEl
>(promiseDom
): PortadomArrayPromise
<El
, BaseEl
>
Wrapper for a Promise that resolves to a n Array of Portadom instances. This allows us to chain Portadom methods before the Promise is resolved.
Example:
const dom = Promise.resolve(browserPortadom({}));
Instead of:
const resA = await (await dom).findOne('..');
const resB = await (await dom).text();
You can call:
const domP = createPortadomArrayPromise(dom);
const resA = await domP.findOne('..');
const resB = await domP.text();
Name |
---|
El |
BaseEl |
Name | Type |
---|---|
promiseDom |
MaybePromise <Portadom <El , BaseEl >[]> |
PortadomArrayPromise
<El
, BaseEl
>
▸ createPortadomPromise<El
, BaseEl
>(promiseDom
): PortadomPromise
<El
, BaseEl
>
Wrapper for a Promise that resolves to a Portadom instance. This allows us to chain Portadom methods before the Promise is resolved.
Example:
const dom = Promise.resolve(browserPortadom({}));
Instead of:
const resA = await (await dom).findOne('..');
const resB = await (await dom).text();
You can call:
const domP = createPortadomPromise(dom);
const resA = await domP.findOne('..');
const resB = await domP.text();
Name |
---|
El |
BaseEl |
Name | Type |
---|---|
promiseDom |
MaybePromise <null | Portadom <El , BaseEl >> |
PortadomPromise
<El
, BaseEl
>
▸ handleIsLocator<T
>(h
): h is Locator
Name |
---|
T |
Name | Type |
---|---|
h |
HandleLike <T > |
h is Locator
▸ mergeHandles<T
>(handles
, options?
): Promise
<JSHandle
<T
[]>>
Join several Locators and Handles in a single JSHandle.
Locators are evaluated to their matching elements.
To override how Locators are resolved, supply own locatorResolver
function.
Name | Type |
---|---|
T |
any |
Name | Type |
---|---|
handles |
HandleLike <T >[] |
options? |
Object |
options.locatorResolver? |
(loc : Locator ) => MaybePromise <MaybeArray <AnyHandle <T >>> |
Promise
<JSHandle
<T
[]>>
▸ playwrightHandlePortadom<El
>(node
, page
): PlaywrightHandlePortadom
<El
>
Implementation of Portadom in Playwright using Handles
Name | Type |
---|---|
El |
extends ElementHandle <Node > | Locator |
Name | Type |
---|---|
node |
El |
page |
Page |
▸ playwrightLocatorPortadom<El
>(node
, page
): PlaywrightLocatorPortadom
<El
>
Implementation of Portadom in Playwright using Locators
Name | Type |
---|---|
El |
extends Locator |
Name | Type |
---|---|
node |
El |
page |
Page |
▸ playwrightPortapage<T
>(page
): Promise
<PlaywrightPortapage
<T
>>
Implementation of Portapage in Playwright
Name | Type |
---|---|
T |
extends Page <T > |
Name | Type |
---|---|
page |
T |
Promise
<PlaywrightPortapage
<T
>>
▸ splitCheerioSelection(cheerioSel
): Cheerio
<AnyNode
>[]
Given a Cheerio selection, split it into an array of Cheerio selections, where each has only one element.
From Cheerio[el, el, el, el]
To [Cheerio[el], Cheerio[el], Cheerio[el], Cheerio[el]]
Name | Type |
---|---|
cheerioSel |
Cheerio <AnyNode > |
Cheerio
<AnyNode
>[]
▸ splitPlaywrightSelection<T
>(handle
): Promise
<SmartHandle
<T
>[]>
Given a Playwright JSHandle that points to an array of Elements, split it into an array of ElementHandles, where each has only one element.
From JSHandle([el, el, el)]
To ElHandle(el), ElHandle(el), ElHandle(el)
Name |
---|
T |
Name | Type |
---|---|
handle |
JSHandle <T []> |
Promise
<SmartHandle
<T
>[]>