diff options
Diffstat (limited to 'activestorage/app')
-rw-r--r-- | activestorage/app/javascript/activestorage/helpers.js | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/activestorage/app/javascript/activestorage/helpers.js b/activestorage/app/javascript/activestorage/helpers.js index 52fec8f6f1..7e83c447e7 100644 --- a/activestorage/app/javascript/activestorage/helpers.js +++ b/activestorage/app/javascript/activestorage/helpers.js @@ -23,11 +23,20 @@ export function findElement(root, selector) { } export function dispatchEvent(element, type, eventInit = {}) { + const { disabled } = element const { bubbles, cancelable, detail } = eventInit const event = document.createEvent("Event") + event.initEvent(type, bubbles || true, cancelable || true) event.detail = detail || {} - element.dispatchEvent(event) + + try { + element.disabled = false + element.dispatchEvent(event) + } finally { + element.disabled = disabled + } + return event } |