javascript-tutorial / javascript-tutorial/en.javascript.info
Add CSS.escape() to DOM searching chapter
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 25.5k
- Forks
- 4k
- PR merge metrics
- No merged PRs in 30d
Description
Hello, I was wondering if it would be worth adding something in the chapter _Searching: getElement, querySelector_ about how to pass a variable through `document.querySelector` by using `CSS.escape()`, ie `document.querySelector('div.' + CSS.escape(userColor))`
I write this because I just spent a while trying template literals, etc, and I had no idea CSS.escape() existed and is necessary to do this.
It's probably pretty uncommon to need to pass variables to querySelector, but if anyone else thinks it's worth adding I would be happy to make a PR.
[https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape](url)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the “Searching: getElement, querySelector” chapter mentioned in the issue and review its existing querySelector examples. Check the linked MDN CSS.escape() reference for accurate guidance; done means the chapter clearly explains passing a variable safely to querySelector and includes a suitable example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100