X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Foffset.js;h=f80574eeae562a4207c9c2a52c6a23bc55d2c51f;hb=9195107dbb13ad34ae4e9f7cb1df5d79e4748560;hp=7dd71343e08355e5071262cc2940fbc138bfcc15;hpb=4fa00369f00b8ee708c8962135b7aa345e3d30d0;p=jquery.git diff --git a/src/offset.js b/src/offset.js index 7dd7134..f80574e 100644 --- a/src/offset.js +++ b/src/offset.js @@ -2,16 +2,16 @@ if ( "getBoundingClientRect" in document.documentElement ) { jQuery.fn.offset = function( options ) { var elem = this[0]; - if ( !elem || !elem.ownerDocument ) { - return null; - } - if ( options ) { return this.each(function( i ) { - jQuery.offset.setOffset( this, i, options ); + jQuery.offset.setOffset( this, options, i ); }); } + if ( !elem || !elem.ownerDocument ) { + return null; + } + if ( elem === elem.ownerDocument.body ) { return jQuery.offset.bodyOffset( elem ); } @@ -28,16 +28,16 @@ if ( "getBoundingClientRect" in document.documentElement ) { jQuery.fn.offset = function( options ) { var elem = this[0]; - if ( !elem || !elem.ownerDocument ) { - return null; - } - if ( options ) { return this.each(function( i ) { - jQuery.offset.setOffset( this, i, options ); + jQuery.offset.setOffset( this, options, i ); }); } + if ( !elem || !elem.ownerDocument ) { + return null; + } + if ( elem === elem.ownerDocument.body ) { return jQuery.offset.bodyOffset( elem ); } @@ -137,7 +137,7 @@ jQuery.offset = { return { top: top, left: left }; }, - setOffset: function( elem, i, options ) { + setOffset: function( elem, options, i ) { // set position first, in-case top/left are set even on static elem if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) { elem.style.position = "relative";