-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
SyntaxError: Failed to execute 'querySelector' on 'Element': '#div-2.1' is not a valid selector #37858
Comments
@larseggert this is weird... did not take the time to look at, but If I copy-paste: const parseSelector = selector => {
if (selector && window.CSS && window.CSS.escape) {
// document.querySelector needs escaping to handle IDs (html5+) containing for instance /
selector = selector.replaceAll(/#([^\s"#']+)/g, (match, id) => '#' + CSS.escape(id))
}
return selector
} in my JS Console in Firefox, and then I type: parseSelector("#div-2.1")
"#div-2\\.1" => Looks like the correct result to me |
Hm. Apply the patch and run the tests? That should recreate the issue. (Maybe that function isn't called?) |
Here is the test failure I get with the patch above:
|
OK, I'm not familiar with the bootstrap code, but to me it looks like |
I have a similar problem but with a tab linking to an external PDF file, using the "file.pdf#page=10" format.
I got JS errors:
|
+1. I am also seeing this issue on Bootstrap v5.2.3, running Microsoft Edge v112 on Windows 11. <h2 id="2-partition-normalized-cut">2-partition: Normalized Cut</h2> causes the error
It seems like #34412 (which was supposed to be closed by #35566) is actually still not solved. |
Can confirm on 5.3.2. Patching findOne(selector, element = document.documentElement) {
- return Element.prototype.querySelector.call(element, selector);
+ return Element.prototype.querySelector.call(element, parseSelector(selector));
}, |
Prerequisites
Describe the issue
#35566 didn't fix things for all weird IDs. The test case addition below causes the error in the issue title.
Reduced test cases
What operating system(s) are you seeing the problem on?
macOS
What browser(s) are you seeing the problem on?
Firefox
What version of Bootstrap are you using?
v5.2.3
The text was updated successfully, but these errors were encountered: