mirror of https://github.com/rails/rails
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
This commit is contained in:
parent
17ad4eb6fb
commit
049a3374aa
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue