Skip to content

Commit

Permalink
Use native requestSubmit instead of custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
nanaya committed Nov 3, 2024
1 parent 06c3963 commit 9e21dc1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
20 changes: 1 addition & 19 deletions app/javascript/src/legacy/common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ window.InitTextAreas = ->
AllowTextAreaFields: true
Element: elem
}, (f) ->
$(form).simulate_submit()
form.requestSubmit()
return
return
return
Expand All @@ -89,24 +89,6 @@ window.InitAdvancedEditing = ->
$(document.documentElement).removeClassName 'hide-advanced-editing'
return

### When we resume a user submit after logging in, we want to run submit events, as
# if the submit had happened normally again, but submit() doesn't do this. Run
# a submit event manually.
###

Element.addMethods 'FORM', simulate_submit: (form) ->
form = $(form)
if document.createEvent
e = document.createEvent('HTMLEvents')
e.initEvent 'submit', true, true
form.dispatchEvent e
if !e.stopped
form.submit()
else
if form.fireEvent('onsubmit')
form.submit()
return

window.onerror = (error, file, line) ->
ReportError error, file, line, null
return
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/legacy/post.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ window.Post =
$(field_id).observe 'keydown', (e) ->
if e.keyCode == Event.KEY_RETURN
e.stop()
@up('form').simulate_submit()
@up('form').requestSubmit()
return
return
get_post_tags_by_type: (post) ->
Expand Down

0 comments on commit 9e21dc1

Please sign in to comment.