From: Dave Methvin Date: Tue, 16 Aug 2011 19:40:09 +0000 (-0400) Subject: Remove redundancy in the IE special submit handler. X-Git-Tag: 1.7b1~61 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8a6bbc70d07e78d0ff84f174d0d17c11a743e2c9;p=jquery.git Remove redundancy in the IE special submit handler. --- diff --git a/src/event.js b/src/event.js index 7f5e30775..81a66c37f 100644 --- a/src/event.js +++ b/src/event.js @@ -32,7 +32,7 @@ var rnamespaces = /\.(.*)$/, (!m[4] || elem.getAttribute( m[4] ) == m[5]) && (!m[6] || !elem[ m[6] ]) ); - } + }; function useNativeMethod( event ) { if ( !event.isDefaultPrevented() && this[ event.type ] ) { @@ -730,25 +730,18 @@ if ( !jQuery.support.submitBubbles ) { jQuery.event.special.submit = { setup: function() { + // Only need this for delegated form submit events if ( jQuery.nodeName( this, "form" ) ) { return false; } - jQuery.event.add(this, "click._submit", function( e ) { - var elem = e.target, - type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; - - trigger( "submit", this, arguments ); - if ( (type === "submit" || type === "image") && elem.form ) { - simulate( "submit", this, e ); - } - }); - - jQuery.event.add(this, "keypress._submit", function( e ) { + jQuery.event.add(this, "click._submit keypress._submit", function( e ) { var elem = e.target, type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; - if ( (type === "text" || type === "password") && elem.form && e.keyCode === 13 ) { + // Do the elem.form check after type to avoid VML-related crash in IE (#TODO) + if ( (e.type === "click" && (type === "submit" || type === "image") && elem.form) || + (e.type === "keypress" && e.keyCode === 13 && (type === "text" || type === "password") && elem.form) ) { simulate( "submit", this, e ); } });