Skip to content

[css-selectors][css-escape] Cannot select attributes with multiple escaped chars #4820

@apollolux

Description

@apollolux

Hello! As someone who isn't part of the WG I wasn't sure where to report the issue so this looked like a reasonable place to do so.

I recently had occasion to want to select an HTML element with an attribute that has a Windows-formatted file path as its main content (i.e. backslash directory separators and a colon separating drive letter and the rest of the path). I asked on Stack Overflow if it was possible, as I was using JavaScript to querySelector it and all my attempts to escape the backslashes and colon, either using CSS.escape or manually, have failed beyond the first escaped char. Microsoft Visual Studio Code, when on Windows, is what formats paths Windows-style, while on macOS and *nix paths separate with / and targeting seems okay. Sample element and failed selector (actual HTML from VSCode in the Stack Overflow):

<li data-path="c:\WINDOWS\system32\mspaint.exe">mspaint.exe</li>
li[data-path="c\:\\WINDOW\\system32\\mspaint\.exe"]

Is there something I'm missing regarding how to escape the attribute, or is it a fruitless endeavor to try to target an attribute that has a Windows-style path in it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closed as Question AnsweredUsed when the issue is more of a question than a problem, and it's been answered.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions