Skip to content

Commit

Permalink
Merge pull request #31574 from Fudoshiki/patch-1
Browse files Browse the repository at this point in the history
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 e525107
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -10,6 +10,11 @@ if typeof CustomEvent isnt 'function'
CustomEvent = (event, params) -> CustomEvent = (event, params) ->
evt = document.createEvent('CustomEvent') evt = document.createEvent('CustomEvent')
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail) 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 evt
CustomEvent.prototype = window.Event.prototype CustomEvent.prototype = window.Event.prototype


Expand Down

0 comments on commit e525107

Please sign in to comment.