benlesh / event-target-polyfill

An EventTarget Polyfill

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Event being polyfilled while valid, with EventTarget not being polyfilled while valid in Chrome.

upcastdrake opened this issue · comments

I'm trying to use this package for backwards compatibility with older devices.

In my testing on the latest Chrome, EventTarget is not being polyfilled as it's native (expected), however Event is being polyfilled, even though it's also native. It looks like this is a deficiency in the isConstructor check the module does on root.Event. The native Event throws an error with new fn() Uncaught TypeError: Failed to construct 'Event': 1 argument required, but only 0 present.. The current implementation takes this to mean Event is not implemented natively, and overwrites it with the polyfill implementation.

This causes issues in the native implementation of EventTarget, as it checks that the events passed in to dispatchEvent are instances of the native Event. The polyfilled Event instanced do not work with the native EventTarget.