mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Prevent form submits from changing the window URL
Refs atom/settings-view#341
This commit is contained in:
parent
170a71f416
commit
e693254913
@ -169,6 +169,14 @@ describe "Window", ->
|
||||
$("<a href='#scroll-me'>link</a>").appendTo(document.body).click().remove()
|
||||
expect(shell.openExternal).not.toHaveBeenCalled()
|
||||
|
||||
describe "when a form is submitted", ->
|
||||
it "prevents the default so that the window's URL isn't changed", ->
|
||||
submitSpy = jasmine.createSpy('submit')
|
||||
$(document).on('submit', 'form', submitSpy)
|
||||
$("<form>foo</form>").appendTo(document.body).submit().remove()
|
||||
expect(submitSpy.callCount).toBe 1
|
||||
expect(submitSpy.argsForCall[0][0].isDefaultPrevented()).toBe true
|
||||
|
||||
describe "core:focus-next and core:focus-previous", ->
|
||||
describe "when there is no currently focused element", ->
|
||||
it "focuses the element with the lowest/highest tabindex", ->
|
||||
|
@ -96,6 +96,9 @@ class WindowEventHandler
|
||||
|
||||
@subscribe $(document), 'click', 'a', @openLink
|
||||
|
||||
# Prevent form submits from changing the current window's URL
|
||||
@subscribe $(document), 'submit', 'form', (e) -> e.preventDefault()
|
||||
|
||||
@subscribe $(document), 'contextmenu', (e) ->
|
||||
e.preventDefault()
|
||||
atom.contextMenu.showForEvent(e)
|
||||
|
Loading…
Reference in New Issue
Block a user