From e0a4aa415d988b21c5b666a20ab00823673ffc3d Mon Sep 17 00:00:00 2001 From: Mike Sherov Date: Thu, 10 Nov 2011 21:23:39 -0500 Subject: use for loop instead of jQuery.each in getWH() --- src/css.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/css.js') diff --git a/src/css.js b/src/css.js index 988a274f6..d31543ea1 100644 --- a/src/css.js +++ b/src/css.js @@ -327,20 +327,22 @@ function getWH( elem, name, extra ) { // Start with offset property var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, - which = name === "width" ? cssWidth : cssHeight; + which = name === "width" ? cssWidth : cssHeight, + i = 0, + len = which.length; if ( val > 0 ) { if ( extra !== "border" ) { - jQuery.each( which, function() { + for ( ; i < len; i++ ) { if ( !extra ) { - val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; + val -= parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; } if ( extra === "margin" ) { - val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; + val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; } else { - val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; + val -= parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; } - }); + } } return val + "px"; @@ -356,15 +358,15 @@ function getWH( elem, name, extra ) { // Add padding, border, margin if ( extra ) { - jQuery.each( which, function() { - val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; + for ( ; i < len; i++ ) { + val += parseFloat( jQuery.css( elem, "padding" + which[ i ] ) ) || 0; if ( extra !== "padding" ) { - val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; + val += parseFloat( jQuery.css( elem, "border" + which[ i ] + "Width" ) ) || 0; } if ( extra === "margin" ) { - val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; + val += parseFloat( jQuery.css( elem, extra + which[ i ] ) ) || 0; } - }); + } } return val + "px"; -- cgit v1.2.3