javascript-tutorial / javascript-tutorial/en.javascript.info

Add CSS.escape() to DOM searching chapter

Open
#2,856 0 comments 2 reactions 0 assignees View on GitHub
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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.