Skip to content

Commit

Permalink
fix: hardcode binding names (#8993)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Sep 21, 2022
1 parent 31e7b60 commit 7e20554
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions scripts/test-install.sh
Expand Up @@ -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();
})();
Expand Down
2 changes: 1 addition & 1 deletion src/common/AriaQueryHandler.ts
Expand Up @@ -146,7 +146,7 @@ const waitFor: PuppeteerQueryHandler['waitFor'] = async (
element,
selector,
options,
new Set([ariaQuerySelector])
new Map([['ariaQuerySelector', ariaQuerySelector]])
);
if (element) {
await element.dispose();
Expand Down
4 changes: 2 additions & 2 deletions src/common/IsolatedWorld.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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>>>> {
Expand Down
12 changes: 6 additions & 6 deletions src/common/WaitTask.ts
Expand Up @@ -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;
Expand All @@ -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>;

Expand All @@ -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;

Expand All @@ -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);
}
}

Expand All @@ -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);
})
);
Expand Down

0 comments on commit 7e20554

Please sign in to comment.