Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CSS query engine for better ID and class matching #1383

Closed
1 of 4 tasks
inancgumus opened this issue Jun 13, 2024 · 1 comment
Closed
1 of 4 tasks

Improve CSS query engine for better ID and class matching #1383

inancgumus opened this issue Jun 13, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@inancgumus
Copy link
Member

inancgumus commented Jun 13, 2024

What?

Add \\ for each element ID CSS selector that contains a dot (.).

Why?

The current CSS selector engine (v0.51) cannot find the following element:

<input id="dotted.id" type="text" value="dotted" />

When given the following selector query (e.g.):

page.fill('#dotted.id', ...)

However, it can find the element if we query the element like so:

page.fill('#dotted\\.id', ...)

This is because the dot is interpreted as a class selector.

How?

Automatically add \\ for each ID selector that contains a dot.

Tasks

Tasks

  1. enhancement
    inancgumus

Related PR(s)/Issue(s)

No response

@inancgumus inancgumus added the enhancement New feature or request label Jun 13, 2024
@inancgumus inancgumus self-assigned this Jun 13, 2024
@inancgumus inancgumus changed the title Improve CSS ID selectors with a dot Improve CSS query engine for better ID and class matching Jun 13, 2024
@inancgumus
Copy link
Member Author

inancgumus commented Jun 13, 2024

I've changed my mind about this issue and will close it because automatically adding \\ can be problematic. It's because:

  • One can mix an ID selector with a class selector.
  • E.g.: #my.yours could mean an element with the id my and a class yours.
  • Also note that it's a common browser feature: Chromium cannot also select element IDs that contain a dot without the \\ escaping.

A better strategy is to let users escape the dots in CSS queries themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant