Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSS.escape() to DOM searching chapter #2856

Open
robertmcabee opened this issue Feb 5, 2022 · 0 comments
Open

Add CSS.escape() to DOM searching chapter #2856

robertmcabee opened this issue Feb 5, 2022 · 0 comments

Comments

@robertmcabee
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant