Skip to content

Commit

Permalink
jquery core: small size optimizations for val().
Browse files Browse the repository at this point in the history
  • Loading branch information
flesler committed Aug 10, 2008
1 parent db63af1 commit fc38ead
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core.js
Expand Up @@ -357,11 +357,10 @@ jQuery.fn = jQuery.prototype = {
}, },


val: function( value ) { val: function( value ) {
if ( value == undefined ) { if ( value == undefined ) {

var elem = this[0];
if ( this.length ) {
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;


Expand Down Expand Up @@ -393,11 +392,11 @@ 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, "");


} }


Expand Down

0 comments on commit fc38ead

Please sign in to comment.