mirror of
https://github.com/jquery/jquery.git
synced 2026-01-25 16:38:10 -05:00
jquery core: small size optimizations for val().
This commit is contained in:
13
src/core.js
13
src/core.js
@@ -357,11 +357,10 @@ jQuery.fn = jQuery.prototype = {
|
||||
},
|
||||
|
||||
val: function( value ) {
|
||||
if ( value == undefined ) {
|
||||
|
||||
if ( this.length ) {
|
||||
var elem = this[0];
|
||||
if ( value == undefined ) {
|
||||
var elem = this[0];
|
||||
|
||||
if ( elem ) {
|
||||
if( jQuery.nodeName( elem, 'option' ) )
|
||||
return (elem.attributes.value || {}).specified ? elem.value : elem.text;
|
||||
|
||||
@@ -393,11 +392,11 @@ jQuery.fn = jQuery.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
return values;
|
||||
}
|
||||
|
||||
// Everything else, we just grab the value
|
||||
} else
|
||||
return (this[0].value || "").replace(/\r/g, "");
|
||||
return (elem.value || "").replace(/\r/g, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user