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

Selector passed into document.querySelector must be escaped #2546

Open
dogayuksel opened this issue Jun 28, 2023 · 0 comments
Open

Selector passed into document.querySelector must be escaped #2546

dogayuksel opened this issue Jun 28, 2023 · 0 comments

Comments

@dogayuksel
Copy link
Contributor

Describe the bug

Below, selector string is created using the id of the element.

const getPortalNode = (id?: string) =>
document.querySelector(`#${getPortalId(id)}`);

According to https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector

Note: Characters that are not part of standard CSS syntax must be escaped using a backslash character.


To Reproduce

When the high precision price tooltip is activated on a list of MoneyInputs managed by formik, such an exception is thrown:

Screenshot 2023-06-28 at 18 57 43

Expected behavior

Non supported characters in the selector string should be escaped like so (notice double \):

document.querySelector("#portal-tiers\\.1\\.value")

Using CSS.escape(str) seems to be a good solution:
https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape_static

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