aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-09-07 14:03:40 -0700
committerDave Methvin <dave.methvin@gmail.com>2011-09-07 14:03:40 -0700
commit69585ba3c7f4f49b6370f63963b7317698ead861 (patch)
tree33529a6dc854df37b27cb7a01071871636c879f8
parent8e8fa6dc1ad514b0fa20e41faddcb85693d0408a (diff)
parent81c778b2cad268a6208544ae32d2ad5b023051a0 (diff)
downloadjquery-69585ba3c7f4f49b6370f63963b7317698ead861.tar.gz
jquery-69585ba3c7f4f49b6370f63963b7317698ead861.zip
Merge pull request #489 from dmethvin/fix-10208-button-type
Fix #10208. Check for `button` as well as `input`
-rw-r--r--src/event.js5
-rw-r--r--test/unit/event.js6
2 files changed, 8 insertions, 3 deletions
diff --git a/src/event.js b/src/event.js
index 9ff6fae83..1161386fd 100644
--- a/src/event.js
+++ b/src/event.js
@@ -702,8 +702,9 @@ if ( !jQuery.support.submitBubbles ) {
setup: function( data, namespaces ) {
if ( !jQuery.nodeName( this, "form" ) ) {
jQuery.event.add(this, "click.specialSubmit", function( e ) {
+ // Avoid triggering error on non-existent type attribute in IE VML (#7071)
var elem = e.target,
- type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+ type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
trigger( "submit", this, arguments );
@@ -712,7 +713,7 @@ if ( !jQuery.support.submitBubbles ) {
jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
var elem = e.target,
- type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+ type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
trigger( "submit", this, arguments );
diff --git a/test/unit/event.js b/test/unit/event.js
index 4e475da06..c69ba8339 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1633,7 +1633,7 @@ test("live with change", function(){
});
test("live with submit", function() {
- expect(5);
+ expect(7);
var count1 = 0, count2 = 0;
@@ -1659,6 +1659,10 @@ test("live with submit", function() {
equals( count1, 2, "Verify form submit." );
equals( count2, 2, "Verify body submit." );
+ jQuery("#testForm button[name=sub4]")[0].click();
+ equals( count1, 3, "Verify form submit." );
+ equals( count2, 3, "Verify body submit." );
+
jQuery("#testForm").die("submit");
jQuery("#testForm input[name=sub1]").die("click");
jQuery("body").die("submit");