aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/app
diff options
context:
space:
mode:
authorYuri S <Fudoshiki@users.noreply.github.com>2017-12-27 18:39:44 +0500
committerGitHub <noreply@github.com>2017-12-27 18:39:44 +0500
commit049a3374aa85f33091f0e7cba8635edd4b4786bd (patch)
tree215ac4cf8aaa469c9af73be60069672e86ef061c /actionview/app
parent17ad4eb6fb25e0c1dbd6772718a9097d63b64ad2 (diff)
downloadrails-049a3374aa85f33091f0e7cba8635edd4b4786bd.tar.gz
rails-049a3374aa85f33091f0e7cba8635edd4b4786bd.tar.bz2
rails-049a3374aa85f33091f0e7cba8635edd4b4786bd.zip
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
Diffstat (limited to 'actionview/app')
-rw-r--r--actionview/app/assets/javascripts/rails-ujs/utils/event.coffee5
1 files changed, 5 insertions, 0 deletions
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