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

Replace event.which + remove event.delegateTarget + fix crash

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/tkrotoff/replace-event.which into master Apr 15, 2020
  • Overview 2
  • Commits 4
  • Pipelines 0
  • Changes 8

Created by: tkrotoff

Following https://github.com/twbs/bootstrap/issues/19991#issuecomment-606050071

3 commits

Replace event.which

KeyboardEvent.which and MouseEvent.which are deprecated/non standard.

It's a relic from the jQuery time.

Replaced with KeyboardEvent.key and MouseEvent.button.

Remove event.delegateTarget inside event-handler.js

event.delegateTarget is only used by tooltip, replacing it with event.target works fine, thus no more fixEvent().

Fix crash in dropdown: "Uncaught TypeError: Cannot read property 'focus' of undefined"

While working on this, I've noticed a crash when opening the dropdown and pressing ArrowUp for the first time. Crash already present here: https://twbs-bootstrap.netlify.com/docs/4.3/components/dropdowns/

https://github.com/twbs/bootstrap/blob/f0abe26b98ade4d6a2d0b234758a94ea33b85388/js/src/dropdown.js#L482

items.indexOf(event.target) || 0 gives -1 || 0 which returns... -1... See explanations "Why are JavaScript negative numbers not always true or false?"

Testing

All tests passing, manually tested (dropdown, tooltip, carousel, tooltip) under macOS with Chrome 81, Firefox 75 and Safari 13.1.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/tkrotoff/replace-event.which