mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Enable MutationObserver attributes (#499)
This patch fixes page.waitForSelector to resolve on attribute changes. Fixes #474.
This commit is contained in:
parent
a756bc868f
commit
8fe2477850
@ -497,7 +497,8 @@ async function waitForPredicatePageFunction(predicateBody, polling, timeout) {
|
|||||||
});
|
});
|
||||||
observer.observe(document, {
|
observer.observe(document, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true,
|
||||||
|
attributes: true
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -451,6 +451,15 @@ describe('Page', function() {
|
|||||||
expect(error).toBeTruthy();
|
expect(error).toBeTruthy();
|
||||||
expect(error.message).toContain('waiting failed: timeout');
|
expect(error.message).toContain('waiting failed: timeout');
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
it('should respond to node attribute mutation', SX(async function() {
|
||||||
|
let divFound = false;
|
||||||
|
const waitForSelector = page.waitForSelector('.zombo').then(() => divFound = true);
|
||||||
|
await page.setContent(`<div class='notZombo'></div>`);
|
||||||
|
expect(divFound).toBe(false);
|
||||||
|
await page.evaluate(() => document.querySelector('div').className = 'zombo');
|
||||||
|
expect(await waitForSelector).toBe(true);
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Page.waitFor', function() {
|
describe('Page.waitFor', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user