fix: hardcode binding names (#8993)
This commit is contained in:
parent
31e7b608d5
commit
7e2055433e
@ -78,6 +78,7 @@ import puppeteer from 'puppeteer';
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto('http://example.com');
|
||||
await page.\$('aria/example');
|
||||
await page.screenshot({ path: 'example.png' });
|
||||
await browser.close();
|
||||
})();
|
||||
|
@ -146,7 +146,7 @@ const waitFor: PuppeteerQueryHandler['waitFor'] = async (
|
||||
element,
|
||||
selector,
|
||||
options,
|
||||
new Set([ariaQuerySelector])
|
||||
new Map([['ariaQuerySelector', ariaQuerySelector]])
|
||||
);
|
||||
if (element) {
|
||||
await element.dispose();
|
||||
|
@ -502,7 +502,7 @@ export class IsolatedWorld {
|
||||
root: ElementHandle<Node> | undefined,
|
||||
selector: string,
|
||||
options: WaitForSelectorOptions,
|
||||
bindings = new Set<(...args: never[]) => unknown>()
|
||||
bindings = new Map<string, (...args: never[]) => unknown>()
|
||||
): Promise<JSHandle<unknown> | null> {
|
||||
const {
|
||||
visible: waitForVisible = false,
|
||||
@ -568,7 +568,7 @@ export class IsolatedWorld {
|
||||
polling?: 'raf' | 'mutation' | number;
|
||||
timeout?: number;
|
||||
root?: ElementHandle<Node>;
|
||||
bindings?: Set<(...args: never[]) => unknown>;
|
||||
bindings?: Map<string, (...args: never[]) => unknown>;
|
||||
} = {},
|
||||
...args: Params
|
||||
): Promise<HandleFor<Awaited<ReturnType<Func>>>> {
|
||||
|
@ -26,7 +26,7 @@ import {HandleFor} from './types.js';
|
||||
* @internal
|
||||
*/
|
||||
export interface WaitTaskOptions {
|
||||
bindings?: Set<(...args: never[]) => unknown>;
|
||||
bindings?: Map<string, (...args: never[]) => unknown>;
|
||||
polling: 'raf' | 'mutation' | number;
|
||||
root?: ElementHandle<Node>;
|
||||
timeout: number;
|
||||
@ -37,7 +37,7 @@ export interface WaitTaskOptions {
|
||||
*/
|
||||
export class WaitTask<T = unknown> {
|
||||
#world: IsolatedWorld;
|
||||
#bindings: Set<(...args: never[]) => unknown>;
|
||||
#bindings: Map<string, (...args: never[]) => unknown>;
|
||||
#polling: 'raf' | 'mutation' | number;
|
||||
#root?: ElementHandle<Node>;
|
||||
|
||||
@ -57,7 +57,7 @@ export class WaitTask<T = unknown> {
|
||||
...args: unknown[]
|
||||
) {
|
||||
this.#world = world;
|
||||
this.#bindings = options.bindings ?? new Set();
|
||||
this.#bindings = options.bindings ?? new Map();
|
||||
this.#polling = options.polling;
|
||||
this.#root = options.root;
|
||||
|
||||
@ -82,8 +82,8 @@ export class WaitTask<T = unknown> {
|
||||
}
|
||||
|
||||
if (this.#bindings.size !== 0) {
|
||||
for (const fn of this.#bindings) {
|
||||
this.#world._boundFunctions.set(fn.name, fn);
|
||||
for (const [name, fn] of this.#bindings) {
|
||||
this.#world._boundFunctions.set(name, fn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ export class WaitTask<T = unknown> {
|
||||
if (this.#bindings.size !== 0) {
|
||||
const context = await this.#world.executionContext();
|
||||
await Promise.all(
|
||||
[...this.#bindings].map(async ({name}) => {
|
||||
[...this.#bindings].map(async ([name]) => {
|
||||
return await this.#world._addBindingToContext(context, name);
|
||||
})
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user