Handle event listener functions more gracefully
Related issues: https://github.com/mapbox/mapbox-gl-js/issues/11433 https://github.com/ionic-team/capacitor/issues/4178
Platforms affected
Motivation and Context
Description
Testing
Checklist
- [ ] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [ ] Commit is prefixed with
(platform)if this change only applies to one platform (e.g.(android)) - [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
- [ ] I've updated the documentation if necessary
Good catch!
However, I think we might have to handle truthy non-string arguments as well. window.addEventListener(1, () => {}) does not throw an error either (tested in Chrome). Unfortunately, I could not find anything on input validation of the type argument in https://dom.spec.whatwg.org/#ref-for-dom-eventtarget-addeventlistener%E2%91%A2
window.addEventListener(1, 2) complains about the second arg being no object.
It would be great if we knew the spec for this. Maybe we actually have to do something like evt = String(evt); instead. Like with object keys which are always converted to strings... :man_shrugging:
Have modified implementation to more closely represent behaviour of the real thing. Turns out you can pass undefined as an argument, and it's a valid event label!
Just wondering why this was closed and what became of this? Was a fix merged?