aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-05-25 19:49:50 -0400
committertimmywil <tim.willison@thisismedium.com>2011-05-25 19:49:50 -0400
commitedb2286544270dc53550180e06668e61c231fb5d (patch)
treee89dae0250f8c57839e160d2a4d5cf7e104b562b /src
parent1d1cb582c0f744afaa51a63d374b9ffe0f58d1db (diff)
downloadjquery-edb2286544270dc53550180e06668e61c231fb5d.tar.gz
jquery-edb2286544270dc53550180e06668e61c231fb5d.zip
Return null for outer/inner width/height calls on window/document. Fixes #7557.
Diffstat (limited to 'src')
-rw-r--r--src/css.js6
-rw-r--r--src/dimensions.js10
2 files changed, 11 insertions, 5 deletions
diff --git a/src/css.js b/src/css.js
index 46f6bf31f..10d36b765 100644
--- a/src/css.js
+++ b/src/css.js
@@ -170,6 +170,11 @@ jQuery.each(["height", "width"], function( i, name ) {
get: function( elem, computed, extra ) {
var val;
+ // Tests for window/document
+ if ( !elem.style ) {
+ return null;
+ }
+
if ( computed ) {
if ( elem.offsetWidth !== 0 ) {
val = getWH( elem, name, extra );
@@ -196,7 +201,6 @@ jQuery.each(["height", "width"], function( i, name ) {
if ( val < 0 || val == null ) {
val = elem.style[ name ];
-
// Should return "auto" instead of 0, use 0 for
// temporary backwards-compat
return val === "" || val === "auto" ? "0px" : val;
diff --git a/src/dimensions.js b/src/dimensions.js
index e2d411dd2..1ab92d1dd 100644
--- a/src/dimensions.js
+++ b/src/dimensions.js
@@ -7,15 +7,17 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
// innerHeight and innerWidth
jQuery.fn["inner" + name] = function() {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, "padding" ) ) :
+ var ret;
+ return this[0] && !isNaN( ret = parseFloat(jQuery.css( this[0], type, "padding" )) ) ?
+ ret :
null;
};
// outerHeight and outerWidth
jQuery.fn["outer" + name] = function( margin ) {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
+ var ret;
+ return this[0] && !isNaN( ret = parseFloat(jQuery.css( this[0], type, margin ? "margin" : "border" )) ) ?
+ ret :
null;
};