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
  • !30117

`prev()` function fails when non-element nodes are present

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge master-mc-fix-prev-function into master Feb 01, 2020
  • Overview 2
  • Commits 8
  • Pipelines 0
  • Changes 2

Created by: MartijnCuppens

The prev() function doesn't take nodes other than elements into account. Also we could simplify things a lot using the previousElementSibling property. This property isn't fully supported in IE, it only works for elements, but since the element variable is an element, we can safely use it here.

I've also added an additional test.

I don't think we had this issue in v4, since we relied on jQuery back then.

Ref. https://developer.mozilla.org/en-US/docs/Web/API/NonDocumentTypeChildNode/nextElementSibling


  • v4 (jQuery): https://getbootstrap.com/docs/4.4/components/scrollspy/#example-with-nested-nav
  • v5 (broken): https://twbs-bootstrap.netlify.com/docs/4.3/components/scrollspy/#example-with-nested-nav
  • v5 (fixed): https://deploy-preview-30117--twbs-bootstrap.netlify.com/docs/4.3/components/scrollspy/#example-with-nested-nav
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: master-mc-fix-prev-function