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

attribute containing ; breaks getCSSSelector() #650

Closed
danschalow opened this issue Mar 15, 2024 · 3 comments
Closed

attribute containing ; breaks getCSSSelector() #650

danschalow opened this issue Mar 15, 2024 · 3 comments
Assignees

Comments

@danschalow
Copy link

Finding a selector for this element causes errors:

<a id="calendlyButton" class="button-primary cc--button-frostbite" width="auto" ;="" href="" onclick="Calendly.initPopupWidget({url: 'REDACTED'});return false;">Kostenlose Erstberatung anfragen</a>

Error

Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Document': '[;]' is not a valid selector.

If you look closely, although odd, the attribute ;="" is in the html.

Suggestion
Use CSS.escape to escape the value: https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape_static

@danschalow
Copy link
Author

Suggestion: #651

@fczbkk fczbkk closed this as completed in 52d159e Mar 15, 2024
@fczbkk fczbkk self-assigned this Mar 15, 2024
@fczbkk
Copy link
Owner

fczbkk commented Mar 15, 2024

Hey @danschalow, thanks for the bug report. I have published v3.6.7, which contains a fix for this issue.

I did not use your pull request, because I used a more generic fix that uses an existing escaping function. You can see my changes in this commit:
52d159e

The CSS Selector Generator should now work properly even on this abomination:

<div aaa:bbb="ccc" ddd;eee="fff" :="ggg" ;="hhh" : ; />

@danschalow
Copy link
Author

Good stuff! Thanks for the quick feedback

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

2 participants