Skip to content

Commit 68541c6

Browse files
committed
fix crash when registering selector engine in playwright >=1.53
1 parent b5c4f23 commit 68541c6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/node/main.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import type { selectors } from 'playwright-core'
55
export type SelectorEngine = Parameters<typeof selectors.register>[1]
66

77
const selectorEngine = (fileName: string): SelectorEngine => ({
8-
// https://github.com/microsoft/playwright/issues/16705
9-
content: `(() => {${readFileSync(
10-
join(__dirname, `../../dist/browser/${fileName}.js`),
11-
'utf8',
12-
)};return module.exports.default})()`,
8+
// https://github.com/microsoft/playwright/issues/36448
9+
content: `(() => {
10+
if (typeof 'module' === undefined) {
11+
window.module = {exports: {}};
12+
}
13+
${readFileSync(join(__dirname, `../../dist/browser/${fileName}.js`), 'utf8')};
14+
return module.exports.default
15+
})()`,
1316
})
1417

1518
export const css = selectorEngine('css')

0 commit comments

Comments
 (0)