W3C home > Mailing lists > Public > public-css-archive@w3.org > March 2020

Re: [csswg-drafts] [css-selectors][css-escape] Cannot select attributes with multiple escaped chars (#4820)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Tue, 03 Mar 2020 22:51:45 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-594212559-1583275904-sysbot+gh@w3.org>
> It seems that the thing I'm ACTUALLY missing which you seem to have ACCIDENTALLY gotten right in your attempt to point out a typo rather than give an actual explanation

Snark is neither appreciated nor useful.

> is the use of String.raw instead of a plain string. Also doesn't help non-JavaScript selection, but at least this is something.

Yeah, note that you need to escape the backslash *both* at the JS *and* the CSS level if you're putting this in querySelector(), because it gets parsed by both languages. Without `String.raw`, you thus have to double-escape, like `querySelector('[data-path^="c:\\\\WINDOWS\\\\system32\\\\mspaint.exe"]')`, which just gets a bit silly.

Inside of a stylesheet you only need to escape it once, since only CSS will be parsing it, so `[data-path^="c:\\WINDOWS..."]` is fine.

GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4820#issuecomment-594212559 using your GitHub account
Received on Tuesday, 3 March 2020 22:51:46 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:02 UTC