Bug Tracker

Ticket #9303 (closed bug: invalid)

Opened 3 years ago

Last modified 2 years ago

.submit broken on form element

Reported by: Jonathan Horowitz <jhorowitz@…> Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

Description

This bug affects all versions of jQuery since 1.4.1, but is readily apparent as of 1.6 due to the removal of the try...catch block originally intended to fix bug #3533, which was also catching the error thrown by this bug.

It seems to have been introduced by the fix for bug #5695.

I have reproduced this bug on Firefox 4.0.1 (on Gentoo Linux 32bit) and IE 8.0.6001.18702 (on Windows XP Pro, 32bit).

To reproduce, simply use the .submit() function as per the API. E.g.:

$("form").submit();

What should happen is that the form submits.

What actually happens is that the following error is thrown (In Firefox Firebug console view):

fileName: "javascript:alert('TODO: FIXME')"
lineNumber: 0
message: "stopPropagation is not defined"
name: "ReferenceError"
stack: "onsubmit()@javascript:alert('TODO: FIXME'):0 @:1 ([object Object],[object Array],[object HTMLFormElement])@http://localhost:8080/path/jquery.js:1785 (0,[object HTMLFormElement])@http://localhost:8080/path/jquery.js:2315 ([object Object],(function () {jQuery.event.trigger(type, data, this);}),(void 0))@http://localhost:8080/path/jquery.js:547 ((function () {jQuery.event.trigger(type, data, this);}))@http://localhost:8080/path/jquery.js:240 ("submit")@http://localhost:8080/path/jquery.js:2314 ()@http://localhost:8080/path/jquery.js:2438 caSubmitForm([object Object],"_self")@http://localhost:8080/path/ca2.js:1035 caSubmit([object HTMLAnchorElement],[object Proxy],"4524","","","","_self","false",false,(void 0))@http://localhost:8080/path/ca2.js:1122 onclick([object MouseEvent])@http://localhost:8080/path/servlet:1 "
__proto__: ReferenceError { name="ReferenceError", lineNumber=0}

In IE, an "Object expected" error is thrown.

From my tests, it appears that the call to

form["onsubmit"].apply(...)

is to blame. This calls the onsubmit handler, which contains

stopPropagation();

In v1.4, it would instead call

form["submit"]()

which works fine.

Change History

comment:1 Changed 3 years ago by Jonathan Horowitz <jhorowitz@…>

nevermind... I missed a call in simplifying my example code; the fault lies with me, not jQuery. Please close this.

comment:2 Changed 3 years ago by rwaldron

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to event
Note: See TracTickets for help on using tickets.