Permalink
Browse files

Merge pull request #31574 from Fudoshiki/patch-1

Fix IE 10 and IE 11's broken `preventDefault` for rails-ujs
  • Loading branch information...
guilleiguaran committed Dec 28, 2017
2 parents 41c8e41 + 049a337 commit e525107108955b5b812825fc3c8c3aec9e1364d2
Showing with 5 additions and 0 deletions.
  1. +5 −0 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

0 comments on commit e525107

Please sign in to comment.