@@ -32,7 +32,7 @@ jQuery.offset = {
3232 elem . style . position = "relative" ;
3333 }
3434
35- curOffset = curElem . offset ( ) ;
35+ curOffset = curElem . offset ( ) || { top : 0 , left : 0 } ;
3636 curCSSTop = jQuery . css ( elem , "top" ) ;
3737 curCSSLeft = jQuery . css ( elem , "left" ) ;
3838 calculatePosition = ( position === "absolute" || position === "fixed" ) &&
@@ -57,10 +57,10 @@ jQuery.offset = {
5757 }
5858
5959 if ( options . top != null ) {
60- props . top = ( options . top - ( curOffset ? curOffset . top : 0 ) ) + curTop ;
60+ props . top = ( options . top - curOffset . top ) + curTop ;
6161 }
6262 if ( options . left != null ) {
63- props . left = ( options . left - ( curOffset ? curOffset . left : 0 ) ) + curLeft ;
63+ props . left = ( options . left - curOffset . left ) + curLeft ;
6464 }
6565
6666 if ( "using" in options ) {
@@ -93,18 +93,15 @@ jQuery.fn.extend({
9393 rect = elem . getBoundingClientRect ( ) ;
9494
9595 // Make sure element is not hidden (display: none) or disconnected
96- if ( ! rect . width && ! rect . height && ! rect . left &&
97- ! rect . top && ! rect . right && ! rect . bottom ) {
98- return ;
96+ if ( rect . width || rect . height || elem . getClientRects ( ) . length ) {
97+ win = getWindow ( doc ) ;
98+ docElem = doc . documentElement ;
99+
100+ return {
101+ top : rect . top + win . pageYOffset - docElem . clientTop ,
102+ left : rect . left + win . pageXOffset - docElem . clientLeft
103+ } ;
99104 }
100-
101- win = getWindow ( doc ) ;
102- docElem = doc . documentElement ;
103-
104- return {
105- top : rect . top + win . pageYOffset - docElem . clientTop ,
106- left : rect . left + win . pageXOffset - docElem . clientLeft
107- } ;
108105 } ,
109106
110107 position : function ( ) {
0 commit comments