Created by: chrisyeh96
This pull request partially addresses issues #34381 (closed) (Scrollspy), #31099 (closed) (Dynamic Tabs), #31005 (closed) (Collapse), and #32826 (closed) (nav-tab anchors).
document.querySelector()
throws an exception when the given selector is not a valid CSS selector, such as when it is an ID-selector starting with a number - e.g., document.querySelector("#3rd")
. (Note that the ID "3rd" is a valid HTML5 id, but "#3rd" is an invalid CSS selector.) This commit catches that exception and returns null instead of propagating that exception.
With this change, the various Bootstrap JS features can now still partially work, instead of failing completely. For example, Scrollspy should now continue to work on elements whose IDs start with ASCII letters, even if there are elements on the same page whose IDs start with digits.
@XhmikosR @ffoodd