Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Fix IE 10 and IE 11's broken preventDefault
Browse files Browse the repository at this point in the history
Fixes #157
  • Loading branch information
dfreedm committed Jun 12, 2015
1 parent c9bceee commit ff1ba94
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CustomElements/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ if (isIE11OrOlder && (typeof window.CustomEvent !== 'function')) {
params = params || {};
var e = document.createEvent('CustomEvent');
e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
// IE does not set `defaultPrevented` when `preventDefault()` is called on
// CustomEvents
// http://stackoverflow.com/questions/23349191/event-preventdefault-is-not-working-in-ie-11-for-custom-events
e.preventDefault = function() {
Object.defineProperty(this, 'defaultPrevented', {
get: function() {
return true;
}
});
};
return e;
};
window.CustomEvent.prototype = window.Event.prototype;
Expand Down

0 comments on commit ff1ba94

Please sign in to comment.