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

Consider using CSS.escape for selectors in JavaScript #675

Open
bsclifton opened this issue Aug 2, 2018 · 0 comments
Open

Consider using CSS.escape for selectors in JavaScript #675

bsclifton opened this issue Aug 2, 2018 · 0 comments
Labels

Comments

@bsclifton
Copy link
Member

@bsclifton bsclifton commented Aug 2, 2018

Carried over from brave/browser-laptop#265

There are certain strings that are valid when used as an HTML element's id or class attributes, but not valid as a CSS selector string. They include strings that begin with numbers, contain spaces, or contain characters with special meaning in CSS. Mathias Bynens's explanation delves into the full details.

The CSS.escape() method provides a convenient way to escape a string so that it conforms to the CSS selector requirements. This is especially useful when dynamically building a CSS selector based on (untrusted) user input.

For more info, see:

@bsclifton bsclifton added this to the Backlog milestone Aug 2, 2018
@bsclifton bsclifton changed the title Consider using CSS.escape Consider using CSS.escape for selectors in JavaScript Aug 2, 2018
@rebron rebron modified the milestone: 1.x Backlog Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.