question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dropdown-item error with external link when using Scrollspy.

See original GitHub issue

Hello! 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinramharakcommented, Jan 23, 2021

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 invalid href attribute value. That is what data-bs-target is for.

1reaction
rohit2sharma95commented, Dec 22, 2020

Dropping support for the class selector in href would be a breaking change, so it is better to keep it for now. 🙂

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found