Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !34410

Fail gracefully on selectors with invalid syntax

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/chrisyeh96/patch-4 into main Jul 03, 2021
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1

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

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/chrisyeh96/patch-4