Skip to content

Can't waitForSelector if the selector contains :focus or something else exotic #23

@JoelEinbinder

Description

@JoelEinbinder

When we do waitForSelector, we poll on DOM mutations. But some things that can change the selectors an element matches against aren't DOM mutations. For example:

const focusedButtonPromise = page.waitForSelector('button:focus');
await page.focus('button');
// times out, because focus doesnt trigger a DOM mutation.
const focusedButton = await focusedButtonPromise; 

Would also effect

  • :focus-within
  • :active
  • :hover
  • :visited (currently broken for other reasons)
  • :empty
  • :valid

Maybe others.

I don't really want to wait on focus changes or value changes for every waitForSelector. Maybe a quick hack that also waits on rafs when the selector contains ":"?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions