From 049a3374aa85f33091f0e7cba8635edd4b4786bd Mon Sep 17 00:00:00 2001 From: Yuri S Date: Wed, 27 Dec 2017 18:39:44 +0500 Subject: Fix IE 10 and IE 11's broken `preventDefault` https://github.com/turbolinks/turbolinks/issues/233 https://stackoverflow.com/questions/23349191/event-preventdefault-is-not-working-in-ie-11-for-custom-events --- actionview/app/assets/javascripts/rails-ujs/utils/event.coffee | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionview') diff --git a/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee b/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee index a2135c9851..c8fbc64b51 100644 --- a/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee +++ b/actionview/app/assets/javascripts/rails-ujs/utils/event.coffee @@ -10,6 +10,11 @@ if typeof CustomEvent isnt 'function' CustomEvent = (event, params) -> evt = document.createEvent('CustomEvent') evt.initCustomEvent(event, params.bubbles, 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 + evt.preventDefault = -> + Object.defineProperty this, 'defaultPrevented', get: -> + true evt CustomEvent.prototype = window.Event.prototype -- cgit v1.2.3