Skip to content

Commit

Permalink
Broke out the logic for the bubbling change/submit events so that the…
Browse files Browse the repository at this point in the history
…y aren't bound if they aren't used.
  • Loading branch information
jeresig committed Dec 7, 2009
1 parent 542099a commit 7d36ccf
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/event.js
Expand Up @@ -569,9 +569,11 @@ jQuery.each({
});

// submit delegation
if ( !jQuery.support.submitBubbles ) {

jQuery.event.special.submit = {
setup: function( data, namespaces, fn ) {
if ( !jQuery.support.submitBubbles && this.nodeName.toLowerCase() !== "form" ) {
if ( this.nodeName.toLowerCase() !== "form" ) {
jQuery.event.add(this, "click.specialSubmit." + fn.guid, function( e ) {
var elem = e.target, type = elem.type;

Expand All @@ -588,8 +590,6 @@ jQuery.event.special.submit = {
}
});
}

return false;
},

remove: function( namespaces, fn ) {
Expand All @@ -598,7 +598,11 @@ jQuery.event.special.submit = {
}
};

}

// change delegation, happens here so we have bind.
if ( !jQuery.support.changeBubbles ) {

jQuery.event.special.change = {
filters: {
click: function( e ) {
Expand Down Expand Up @@ -647,21 +651,16 @@ jQuery.event.special.change = {
}
},
setup: function( data, namespaces, fn ) {
// return false if we bubble
if ( !jQuery.support.changeBubbles ) {
for ( var type in changeFilters ) {
jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
}
for ( var type in changeFilters ) {
jQuery.event.add( this, type + ".specialChange." + fn.guid, changeFilters[type] );
}

// always want to listen for change for trigger
return false;
},
remove: function( namespaces, fn ) {
if ( !jQuery.support.changeBubbles ) {
for ( var type in changeFilters ) {
jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
}
for ( var type in changeFilters ) {
jQuery.event.remove( this, type + ".specialChange" + (fn ? "."+fn.guid : ""), changeFilters[type] );
}
}
};
Expand Down

2 comments on commit 7d36ccf

@jaubourg
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a missing '}' somewhere and support module should be put before event module in build files now.

@jeresig
Copy link
Member Author

@jeresig jeresig commented on 7d36ccf Dec 7, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in: 97323d1.

Please sign in to comment.