mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: use shadowRoot for tree walker (#9950)
This commit is contained in:
parent
1396274477
commit
728547d460
@ -49,7 +49,8 @@ export function* pierce(root: Node): IterableIterator<Node | ShadowRoot> {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export function* pierceAll(root: Node): IterableIterator<Node | ShadowRoot> {
|
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)];
|
const walkers = [document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT)];
|
||||||
for (const walker of walkers) {
|
for (const walker of walkers) {
|
||||||
let node: Element | null;
|
let node: Element | null;
|
||||||
|
@ -404,6 +404,24 @@ describe('Query handler tests', function () {
|
|||||||
})
|
})
|
||||||
).toBeTruthy();
|
).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 () => {
|
it('should work with text selectors', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user