Dropdown-item error with external link when using Scrollspy.
See original GitHub issueHello! I am using Bootstrap 5.0.0-alpha3.
<li><a class="dropdown-item" href="https://duckduckgo.com/">other</a></li>
Using Scrollspy I added in a dropdown a dropdown-item that contains a link to an external page (https://duckduckgo.com/) and I get an error in the console.
The error occurs on the following line: https://github.com/twbs/bootstrap/blob/c63aebc86ba05f0ebb420add653b80804c6a0cff/dist/js/bootstrap.bundle.js#L96-L102
If the selector variable is equal to some external link such as “https://duckduckgo.com/”, the following error occurs:
- 'https://duckduckgo.com/' is not a valid selector
My proposal is to enclose it in a try catch:
var selector = getSelector(element);
try {
return document.querySelector(selector) ? selector : null;
} catch (_) {
return null;
}
Operating system: “windows 10”; Browser and version : {“Firefox”:“83.0”, “Microsoft Edge”:“87.0.664.47”};
A reduced test case here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Bootstrap - scrollspy responsivness not working - Stack Overflow
I have another page that has not problem with responsivnes, there I do not use scrollspy. I would like to give you more...
Read more >Bootstrap 4 Scrollspy Tutorial - YouTube
A scrollspy is used to automatically update links in the navigation ... Hey guys, I'm now using Patreon to share improved and updated...
Read more >Dropdowns · Bootstrap v5.1
Overview. Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap ...
Read more >Bootstrap Dropdowns - examples & tutorial
Wrap the dropdown's toggle (your button or link) and the dropdown menu within .dropdown element that declares position: relative; .
Read more >Nav | Components - BootstrapVue
<b-nav-item> supports generating <router-link> or <nuxt-link> component (if using Nuxt.js). For more details on the router link (or nuxt link) specific props, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is this going to land in
5.0.0-beta2
? The PR seems to have an open review. I would agree with the PR that a class selector should be an invalidhref
attribute value. That is whatdata-bs-target
is for.Dropping support for the class selector in href would be a breaking change, so it is better to keep it for now. 🙂