mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
offset returns null for window and document elements. fixes #4136 again
This commit is contained in:
parent
6a049246a1
commit
432ea4ca6c
@ -1,7 +1,7 @@
|
|||||||
if ( "getBoundingClientRect" in document.documentElement )
|
if ( "getBoundingClientRect" in document.documentElement )
|
||||||
jQuery.fn.offset = function() {
|
jQuery.fn.offset = function() {
|
||||||
var elem = this[0];
|
var elem = this[0];
|
||||||
if ( !elem ) return null;
|
if ( !elem || !elem.ownerDocument ) return null;
|
||||||
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
|
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
|
||||||
var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
|
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,
|
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
|
||||||
@ -12,7 +12,7 @@ if ( "getBoundingClientRect" in document.documentElement )
|
|||||||
else
|
else
|
||||||
jQuery.fn.offset = function() {
|
jQuery.fn.offset = function() {
|
||||||
var elem = this[0];
|
var elem = this[0];
|
||||||
if ( !elem ) return null;
|
if ( !elem || !elem.ownerDocument ) return null;
|
||||||
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
|
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
|
||||||
jQuery.offset.initialize();
|
jQuery.offset.initialize();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user