Skip to content

Commit 4d2dac4

Browse files
fix
1 parent 218fa73 commit 4d2dac4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tools/script.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ Example with arguments: \`(el) => {
4747
handler: async (request, response, context) => {
4848
const args: Array<JSHandle<unknown>> = [];
4949
try {
50-
const frames: Frame[] = [];
50+
const frames = new Set<Frame>();
5151
for (const el of request.params.args ?? []) {
5252
const handle = await context.getElementByUid(el.uid);
53-
frames.push(handle.frame);
53+
frames.add(handle.frame);
5454
args.push(handle);
5555
}
5656
let pageOrFrame: Page | Frame;
5757
// We can't evaluate the element handle across frames
58-
if (frames.length > 1) {
58+
if (frames.size > 1) {
5959
throw new Error(
6060
"Elements from different frames can't be evaluated together.",
6161
);
6262
} else {
63-
pageOrFrame = frames[0] ?? context.getSelectedPage();
63+
pageOrFrame = [...frames.values()][0] ?? context.getSelectedPage();
6464
}
6565
const fn = await pageOrFrame.evaluateHandle(
6666
`(${request.params.function})`,

0 commit comments

Comments
 (0)