mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue