fix: use shadowRoot for tree walker (#9950)

This commit is contained in:
jrandolf 2023-03-31 17:19:59 +02:00 committed by GitHub
parent 1396274477
commit 728547d460
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -49,7 +49,8 @@ export function* pierce(root: Node): IterableIterator<Node | ShadowRoot> {
* @internal
*/
export function* pierceAll(root: Node): IterableIterator<Node | ShadowRoot> {
yield* pierce(root);
root = pierce(root).next().value;
yield root;
const walkers = [document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)];
for (const walker of walkers) {
let node: Element | null;

View File

@ -404,6 +404,24 @@ describe('Query handler tests', function () {
})
).toBeTruthy();
}
{
const elements = await page.$$('#c >>>> div');
assert(elements[0], 'Could not find element');
expect(
await elements[0]?.evaluate(element => {
return element.id === 'd';
})
).toBeTruthy();
}
{
const elements = await page.$$('#c >>> div');
assert(elements[0], 'Could not find element');
expect(
await elements[0]?.evaluate(element => {
return element.id === 'd';
})
).toBeTruthy();
}
});
it('should work with text selectors', async () => {