Event listener function overloads are too brittle, error if evt is undefined
- Dominant language
- JavaScript
- Stars
- 642
- Forks
- 811
- Avg merge
- 1h 9m
- Merged PRs (30d)
- 4
Description
The ```document.addEventListener```, ```document.removeEventListener```, ```window.addEventListener```, ```window.removeEventListener``` overloads in ```cordova.js``` error if the ```evt``` variable is undefined. While this is something that also be fixed upstream in the relevant calling code, these functions should not be erroring as that is not the behaviour of what they are overloading.
```
window.addEventListener(undefined, () => {})
```
In cordova.js, the above would cause an error.
In safari/chrome console, no error is triggered.
I have create a PR to address this.
#245
Related:
https://github.com/ionic-team/capacitor/issues/4178
https://github.com/mapbox/mapbox-gl-js/issues/11433
Contributor guide
Research direction
Inspect the four document and window addEventListener/removeEventListener overloads in cordova.js, then review PR #245 for the proposed change. Reproduce the issue with window.addEventListener(undefined, () => {}) and verify that the overloads no longer throw, matching Safari and Chrome behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100