cordova-js icon indicating copy to clipboard operation
cordova-js copied to clipboard

Event listener function overloads are too brittle, error if evt is undefined

Open jpike88 opened this issue 3 years ago • 1 comments

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

jpike88 avatar Jan 24 '22 06:01 jpike88

Adding to this, passing an Event instance instead of a string will also throw an exception when trying to get it converted to a lower case string as for example here: https://github.com/apache/cordova-js/blob/7c2f830418f80a773da04bec0fd0c282556bb41d/src/cordova.js#L47

alexculea avatar Mar 10 '22 16:03 alexculea