Microoptimization in jQuery.attr and remove the redundancy of return undefined

This commit is contained in:
timmywil 2011-11-14 12:31:28 -05:00
parent a8460d24e0
commit 20cbf1b123

View File

@ -177,7 +177,7 @@ jQuery.fn.extend({
ret == null ? "" : ret; ret == null ? "" : ret;
} }
return undefined; return;
} }
isFunction = jQuery.isFunction( value ); isFunction = jQuery.isFunction( value );
@ -302,7 +302,7 @@ jQuery.extend({
// don't get/set attributes on text, comment and attribute nodes // don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return;
} }
if ( pass && name in jQuery.attrFn ) { if ( pass && name in jQuery.attrFn ) {
@ -310,7 +310,7 @@ jQuery.extend({
} }
// Fallback to prop when attributes are not supported // Fallback to prop when attributes are not supported
if ( !("getAttribute" in elem) ) { if ( typeof elem.getAttribute === "undefined" ) {
return jQuery.prop( elem, name, value ); return jQuery.prop( elem, name, value );
} }
@ -327,7 +327,7 @@ jQuery.extend({
if ( value === null ) { if ( value === null ) {
jQuery.removeAttr( elem, name ); jQuery.removeAttr( elem, name );
return undefined; return;
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret; return ret;
@ -439,7 +439,7 @@ jQuery.extend({
// don't get/set properties on text, comment and attribute nodes // don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined; return;
} }
notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); notxml = nType !== 1 || !jQuery.isXMLDoc( elem );