aboutsummaryrefslogtreecommitdiffstats
path: root/src/css.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2011-11-10 21:23:39 -0500
committerDave Methvin <dave.methvin@gmail.com>2011-11-10 21:59:45 -0500
commite0a4aa415d988b21c5b666a20ab00823673ffc3d (patch)
treec349f10e211d0faac38e13f009b2b5c022958f70 /src/css.js
parent774eba33881093efa592d350a831ca1a812428a8 (diff)
downloadjquery-e0a4aa415d988b21c5b666a20ab00823673ffc3d.tar.gz
jquery-e0a4aa415d988b21c5b666a20ab00823673ffc3d.zip
use for loop instead of jQuery.each in getWH()
Diffstat (limited to 'src/css.js')
-rw-r--r--src/css.js24
1 files changed, 13 insertions, 11 deletions
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";