Updated formatting for the change/submit special event logic. Also switched the function declarations to statements. Thanks to Garrett for the recommendation.

This commit is contained in:
jeresig 2010-02-08 23:28:15 -05:00
parent fec02aa5cb
commit 5267824aa3

View file

@ -652,7 +652,7 @@ jQuery.each({
// submit delegation
if ( !jQuery.support.submitBubbles ) {
jQuery.event.special.submit = {
jQuery.event.special.submit = {
setup: function( data, namespaces ) {
if ( this.nodeName.toLowerCase() !== "form" ) {
jQuery.event.add(this, "click.specialSubmit", function( e ) {
@ -680,16 +680,18 @@ jQuery.event.special.submit = {
jQuery.event.remove( this, "click.specialSubmit" );
jQuery.event.remove( this, "keypress.specialSubmit" );
}
};
};
}
// change delegation, happens here so we have bind.
if ( !jQuery.support.changeBubbles ) {
var formElems = /textarea|input|select/i;
var formElems = /textarea|input|select/i,
function getVal( elem ) {
changeFilters,
getVal = function( elem ) {
var type = elem.type, val = elem.value;
if ( type === "radio" || type === "checkbox" ) {
@ -707,9 +709,9 @@ function getVal( elem ) {
}
return val;
}
},
function testChange( e ) {
testChange = function testChange( e ) {
var elem = e.target, data, val;
if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
@ -732,9 +734,9 @@ function testChange( e ) {
e.type = "change";
return jQuery.event.trigger( e, arguments[1], elem );
}
}
};
jQuery.event.special.change = {
jQuery.event.special.change = {
filters: {
focusout: testChange,
@ -782,10 +784,9 @@ jQuery.event.special.change = {
return formElems.test( this.nodeName );
}
};
var changeFilters = jQuery.event.special.change.filters;
};
changeFilters = jQuery.event.special.change.filters;
}
function trigger( type, elem, args ) {