From 432ea4ca6cbd63cd972718d3a44772fe8ef1022b Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Wed, 22 Apr 2009 05:29:01 +0000 Subject: [PATCH] offset returns null for window and document elements. fixes #4136 again --- src/offset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/offset.js b/src/offset.js index 92eace9..964844e 100644 --- a/src/offset.js +++ b/src/offset.js @@ -1,7 +1,7 @@ if ( "getBoundingClientRect" in document.documentElement ) jQuery.fn.offset = function() { var elem = this[0]; - if ( !elem ) return null; + if ( !elem || !elem.ownerDocument ) return null; if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, @@ -12,7 +12,7 @@ if ( "getBoundingClientRect" in document.documentElement ) else jQuery.fn.offset = function() { var elem = this[0]; - if ( !elem ) return null; + if ( !elem || !elem.ownerDocument ) return null; if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); jQuery.offset.initialize(); -- 1.7.10.4