mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
jquery core: small size optimizations for val().
This commit is contained in:
parent
db63af1068
commit
fc38ead4dc
@ -358,10 +358,9 @@ jQuery.fn = jQuery.prototype = {
|
||||
|
||||
val: function( value ) {
|
||||
if ( value == undefined ) {
|
||||
var elem = this[0];
|
||||
|
||||
if ( this.length ) {
|
||||
var elem = this[0];
|
||||
|
||||
if ( elem ) {
|
||||
if( jQuery.nodeName( elem, 'option' ) )
|
||||
return (elem.attributes.value || {}).specified ? elem.value : elem.text;
|
||||
|
||||
@ -394,10 +393,10 @@ jQuery.fn = jQuery.prototype = {
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
// Everything else, we just grab the value
|
||||
} else
|
||||
return (this[0].value || "").replace(/\r/g, "");
|
||||
return (elem.value || "").replace(/\r/g, "");
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user