Skip to content
Browse files

Fix #10798. Don't re-bubble trigger()ed events in IE.

Since .trigger() already bubbles the event, we don't have to work around the non-bubbling IE events for that case.
  • Loading branch information...
1 parent ca8fc72 commit 80797f5805c335a818bda4237642fc4935bd77f6 @dmethvin dmethvin committed Nov 15, 2011
Showing with 29 additions and 8 deletions.
  1. +4 −4 src/event.js
  2. +25 −4 test/delegatetest.html
View
8 src/event.js
@@ -752,8 +752,8 @@ if ( !jQuery.support.submitBubbles ) {
form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
if ( form && !form._submit_attached ) {
jQuery.event.add( form, "submit._submit", function( event ) {
- // Form was submitted, bubble the event up the tree
- if ( this.parentNode ) {
+ // If form was submitted by the user, bubble the event up the tree
+ if ( this.parentNode && !event.isTrigger ) {
jQuery.event.simulate( "submit", this.parentNode, event, true );
}
});
@@ -793,7 +793,7 @@ if ( !jQuery.support.changeBubbles ) {
}
});
jQuery.event.add( this, "click._change", function( event ) {
- if ( this._just_changed ) {
+ if ( this._just_changed && !event.isTrigger ) {
this._just_changed = false;
jQuery.event.simulate( "change", this, event, true );
}
@@ -807,7 +807,7 @@ if ( !jQuery.support.changeBubbles ) {
if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
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 );
}
});
View
29 test/delegatetest.html
@@ -129,11 +129,28 @@
</tr>
</table>
+ <form id="autosub"><input type=submit name=subme /></form>
+
<script type='text/javascript'>
$("#version").text(version);
$("#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
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;
@@ -179,10 +196,13 @@
}
jQuery.fn.blink = function(){
- return this.css("backgroundColor","green").css("border","solid 3px green").delay(700).queue(function(next){
- jQuery(this).css("backgroundColor","");
- next();
- });
+ return this
+ .css("backgroundColor","green")
+ .text( (parseInt(this.text(), 10) || 0) + 1 )
+ .delay(700).queue(function(next){
+ jQuery(this).css("backgroundColor","#afa");
+ next();
+ });
};
jQuery.fn.addSubmitTest = function( id, prevent ) {
@@ -197,6 +217,7 @@
$("#text_submit").addSubmitTest("#textSubmit", true);
$("#password_submit").addSubmitTest("#passwordSubmit", true);
$("#submit_submit").addSubmitTest("#submitSubmit", true);
+$("#prog_submit").addSubmitTest("#submitSubmit", true);
$(document).bind("submit", function(){
jQuery("#boundSubmit").blink();
});

0 comments on commit 80797f5

Please sign in to comment.
Something went wrong with that request. Please try again.