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

> 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 using your GitHub account

Received on Tuesday, 3 March 2020 22:51:46 UTC