Fix #11049. Let bubbling submit be cancellable in oldIE.

This commit is contained in:
Dave Methvin
2012-03-04 21:11:50 -05:00
parent 619f0d908a
commit 92a92be10f
2 changed files with 64 additions and 8 deletions

View File

@@ -1216,10 +1216,10 @@ test("Delegated events in SVG (#10791)", function() {
test("Delegated events in forms (#10844; #11145; #8165)", function() {
expect(3);
// Aliases names like "id" cause havoc
// Alias names like "id" cause havoc
var form = jQuery(
'<form id="myform">'+
'<input type="text" name="id" value="secret agent man" />'+
'<input type="text" name="id" value="secret agent man" />'+
'</form>'
)
.on( "submit", function( event ) {
@@ -1259,6 +1259,44 @@ test("Delegated events in forms (#10844; #11145; #8165)", function() {
form.remove();
});
test("Submit event can be stopped (#11049)", function() {
expect(1);
// Since we manually bubble in IE, make sure inner handlers get a chance to cancel
var form = jQuery(
'<form id="myform">'+
'<input type="text" name="sue" value="bawls" />'+
'<input type="submit" />'+
'</form>'
)
.appendTo("body");
jQuery( "body" )
.on( "submit", function() {
ok( true, "submit bubbled on first handler" );
return false;
})
.find( "#myform input[type=submit]" )
.each( function(){ this.click(); } )
.end()
.on( "submit", function() {
ok( false, "submit bubbled on second handler" );
return false;
})
.find( "#myform input[type=submit]" )
.each( function(){
jQuery( this.form ).on( "submit", function( e ) {
e.preventDefault();
e.stopPropagation();
});
this.click();
})
.end()
.off( "submit" );
form.remove();
});
test("jQuery.Event( type, props )", function() {
expect(5);
@@ -2664,7 +2702,7 @@ test("clone() delegated events (#11076)", function() {
clicked = function( event ) {
counter[ jQuery(this).text().replace(/\s+/, "") ]++;
},
table =
table =
jQuery( "<table><tr><td>center</td><td>fold</td></tr></table>" )
.on( "click", "tr", clicked )
.on( "click", "td:first-child", clicked )