Commit d47c0ae4 authored by timmywil's avatar timmywil

Performance testing: localize val to each block and only set val to value when not a function

parent 94fff6ff
...@@ -153,15 +153,15 @@ jQuery.fn.extend({ ...@@ -153,15 +153,15 @@ jQuery.fn.extend({
}, },
val: function( value ) { val: function( value ) {
var hooks, val, var hooks, ret,
elem = this[0]; elem = this[0];
if ( !arguments.length ) { if ( !arguments.length ) {
if ( elem ) { if ( elem ) {
hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
if ( hooks && "get" in hooks && (val = hooks.get( elem )) !== undefined ) { if ( hooks && "get" in hooks && (ret = hooks.get( elem )) !== undefined ) {
return val; return ret;
} }
return (elem.value || "").replace(rreturn, ""); return (elem.value || "").replace(rreturn, "");
...@@ -173,15 +173,16 @@ jQuery.fn.extend({ ...@@ -173,15 +173,16 @@ jQuery.fn.extend({
var isFunction = jQuery.isFunction( value ); var isFunction = jQuery.isFunction( value );
return this.each(function( i ) { return this.each(function( i ) {
var self = jQuery(this); var self = jQuery(this), val;
if ( this.nodeType !== 1 ) { if ( this.nodeType !== 1 ) {
return; return;
} }
val = value;
if ( isFunction ) { if ( isFunction ) {
val = value.call( this, i, self.val() ); val = value.call( this, i, self.val() );
} else {
val = value;
} }
// Treat null/undefined as ""; convert numbers to string // Treat null/undefined as ""; convert numbers to string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment