Skip to content

Commit

Permalink
Fix #10798. Don't re-bubble trigger()ed events in IE.
Browse files Browse the repository at this point in the history
Since .trigger() already bubbles the event, we don't have to work around the non-bubbling IE events for that case.
  • Loading branch information
dmethvin committed Nov 16, 2011
1 parent ca8fc72 commit 80797f5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/event.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -752,8 +752,8 @@ if ( !jQuery.support.submitBubbles ) {
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
if ( form && !form._submit_attached ) { if ( form && !form._submit_attached ) {
jQuery.event.add( form, "submit._submit", function( event ) { jQuery.event.add( form, "submit._submit", function( event ) {
// Form was submitted, bubble the event up the tree // If form was submitted by the user, bubble the event up the tree
if ( this.parentNode ) { if ( this.parentNode && !event.isTrigger ) {
jQuery.event.simulate( "submit", this.parentNode, event, true ); jQuery.event.simulate( "submit", this.parentNode, event, true );
} }
}); });
Expand Down Expand Up @@ -793,7 +793,7 @@ if ( !jQuery.support.changeBubbles ) {
} }
}); });
jQuery.event.add( this, "click._change", function( event ) { jQuery.event.add( this, "click._change", function( event ) {
if ( this._just_changed ) { if ( this._just_changed && !event.isTrigger ) {
this._just_changed = false; this._just_changed = false;
jQuery.event.simulate( "change", this, event, true ); jQuery.event.simulate( "change", this, event, true );
} }
Expand All @@ -807,7 +807,7 @@ if ( !jQuery.support.changeBubbles ) {


if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
jQuery.event.add( elem, "change._change", function( event ) { jQuery.event.add( elem, "change._change", function( event ) {
if ( this.parentNode && !event.isSimulated ) { if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
jQuery.event.simulate( "change", this.parentNode, event, true ); jQuery.event.simulate( "change", this.parentNode, event, true );
} }
}); });
Expand Down
29 changes: 25 additions & 4 deletions test/delegatetest.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -129,11 +129,28 @@ <h2>Submit Tests</h2>
</tr> </tr>
</table> </table>


<form id="autosub"><input type=submit name=subme /></form>

<script type='text/javascript'> <script type='text/javascript'>


$("#version").text(version); $("#version").text(version);
$("#fileversion").text($.fn.jquery); $("#fileversion").text($.fn.jquery);


// Try an auto-submit, it should only fire once
$(function(){
var triggered = false;
$("#autosub input").trigger("keypress");
$("body").on("submit", "#autosub", function( e ){
e.preventDefault();
e.stopPropagation();
if ( triggered ) {
alert("autosubmit FAIL");
}
triggered = true;
});
$("#autosub").submit().remove();
});

// Events we want to track in row-order // Events we want to track in row-order
var events = "bind-change live-change on-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "), var events = "bind-change live-change on-change bind-propertychange live-beforeactivate live-focusin bind-focus live-beforedeactivate live-focusout bind-blur live-click live-keydown".split(" "),
counter = 0; counter = 0;
Expand Down Expand Up @@ -179,10 +196,13 @@ <h2>Submit Tests</h2>
} }


jQuery.fn.blink = function(){ jQuery.fn.blink = function(){
return this.css("backgroundColor","green").css("border","solid 3px green").delay(700).queue(function(next){ return this
jQuery(this).css("backgroundColor",""); .css("backgroundColor","green")
next(); .text( (parseInt(this.text(), 10) || 0) + 1 )
}); .delay(700).queue(function(next){
jQuery(this).css("backgroundColor","#afa");
next();
});
}; };


jQuery.fn.addSubmitTest = function( id, prevent ) { jQuery.fn.addSubmitTest = function( id, prevent ) {
Expand All @@ -197,6 +217,7 @@ <h2>Submit Tests</h2>
$("#text_submit").addSubmitTest("#textSubmit", true); $("#text_submit").addSubmitTest("#textSubmit", true);
$("#password_submit").addSubmitTest("#passwordSubmit", true); $("#password_submit").addSubmitTest("#passwordSubmit", true);
$("#submit_submit").addSubmitTest("#submitSubmit", true); $("#submit_submit").addSubmitTest("#submitSubmit", true);
$("#prog_submit").addSubmitTest("#submitSubmit", true);
$(document).bind("submit", function(){ $(document).bind("submit", function(){
jQuery("#boundSubmit").blink(); jQuery("#boundSubmit").blink();
}); });
Expand Down

0 comments on commit 80797f5

Please sign in to comment.