krambuhl / custom-event-polyfill

Polyfill for creating CustomEvents on IE9/10/11 if native implementation is missing.
MIT License
112 stars 19 forks source link

Major Bug - Always overrides native CustomEvent across all browsers #12

Closed andrejpavlovic closed 6 years ago

andrejpavlovic commented 6 years ago

The polyfill test always fails and as a result the browser never uses the native implementation even when it is available.

The issue is with this code: https://github.com/krambuhl/custom-event-polyfill/blob/71749f01e4e8e3e7e52ffb646bb50c4f78f87961/custom-event-polyfill.js#L7-L15

Instead of

var ce = new window.CustomEvent('test'); 

is should be

var ce = new window.CustomEvent('test', {cancelable: true});

otherwise ce.defaultPrevented always equals to false and the error is always thrown.

jbreckmckye commented 6 years ago

@andrejpavlovic Maybe write that up as a PR?

davidpelayo commented 6 years ago

@jbreckmckye when are we merging #13 so this gets closed?

jbreckmckye commented 6 years ago

@davidpelayo I don't know. When ARE we? I'm not a project admin, you tell me.

davidpelayo commented 6 years ago

Fair enough 😆 @krambuhl, when #13 gets merged?

kumarharsh commented 6 years ago

In the meanwhile, you can use this fork which has @andrejpavlovic and @shrpne's changes https://www.npmjs.com/package/@playlyfe/custom-event-polyfill

krambuhl commented 6 years ago

PR has been merged, closing this ticket.