jquery core: small size optimizations for val().

This commit is contained in:
Ariel Flesler 2008-08-10 23:59:01 +00:00
parent db63af1068
commit fc38ead4dc

View file

@ -358,10 +358,9 @@ jQuery.fn = jQuery.prototype = {
val: function( value ) { val: function( value ) {
if ( value == undefined ) { if ( value == undefined ) {
if ( this.length ) {
var elem = this[0]; var elem = this[0];
if ( elem ) {
if( jQuery.nodeName( elem, 'option' ) ) if( jQuery.nodeName( elem, 'option' ) )
return (elem.attributes.value || {}).specified ? elem.value : elem.text; return (elem.attributes.value || {}).specified ? elem.value : elem.text;
@ -394,10 +393,10 @@ jQuery.fn = jQuery.prototype = {
} }
return values; return values;
}
// Everything else, we just grab the value // Everything else, we just grab the value
} else return (elem.value || "").replace(/\r/g, "");
return (this[0].value || "").replace(/\r/g, "");
} }