aboutsummaryrefslogtreecommitdiffstats
path: root/src/dimensions.js
diff options
context:
space:
mode:
authorJohn Resig <jeresig@gmail.com>2009-02-13 22:58:57 +0000
committerJohn Resig <jeresig@gmail.com>2009-02-13 22:58:57 +0000
commit848c45ea17cc03bcabd7ab882359e1c62f9485f5 (patch)
treedd42d482a531593a81fd1b262495d8766d12ec8f /src/dimensions.js
parent7f1eb1c14fdf9a5d149c907df9e331cbecfa9720 (diff)
downloadjquery-848c45ea17cc03bcabd7ab882359e1c62f9485f5.tar.gz
jquery-848c45ea17cc03bcabd7ab882359e1c62f9485f5.zip
Added some significant speed-ups to height/width checks, thanks to some code and investigation by Mike Helgeson. Fixes #3082.
Diffstat (limited to 'src/dimensions.js')
-rw-r--r--src/dimensions.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/dimensions.js b/src/dimensions.js
index 297118457..2ba8f670d 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -2,22 +2,21 @@
jQuery.each([ "Height", "Width" ], function(i, name){
var tl = i ? "Left" : "Top", // top or left
- br = i ? "Right" : "Bottom"; // bottom or right
+ br = i ? "Right" : "Bottom", // bottom or right
+ lower = name.toLowerCase();
// innerHeight and innerWidth
jQuery.fn["inner" + name] = function(){
- return this[ name.toLowerCase() ]() +
- num(this, "padding" + tl) +
- num(this, "padding" + br);
+ return this[0] ?
+ jQuery.css( this[0], lower, false, "padding" ) :
+ null;
};
// outerHeight and outerWidth
jQuery.fn["outer" + name] = function(margin) {
- return this["inner" + name]() +
- num(this, "border" + tl + "Width") +
- num(this, "border" + br + "Width") +
- (margin ?
- num(this, "margin" + tl) + num(this, "margin" + br) : 0);
+ return this[0] ?
+ jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) :
+ null;
};
var type = name.toLowerCase();
@@ -47,4 +46,4 @@ jQuery.each([ "Height", "Width" ], function(i, name){
this.css( type, typeof size === "string" ? size : size + "px" );
};
-}); \ No newline at end of file
+});