I have this ES6 code in Puppeteer:
async function waitForSelectorReversed(page, selector) {
await page.waitFor(() => !document.querySelector(selector));
}
When I call this code I get the error Evaluation failed: ReferenceError: selector is not defined
. I understand that this error is caused by the fact that the code inside the closure can't access the variable from the outer scope. What is a way of getting this to work?