diff options
author | Karl Swedberg <karl@englishrules.com> | 2010-01-21 23:18:54 +0800 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2010-01-24 01:26:35 +0800 |
commit | 2c28f229e5eb49f1469fd36ee979529a492f0f42 (patch) | |
tree | 6a77ec6fee0525fd398dfea75ec69bd95d82b7d5 /src/offset.js | |
parent | a63754aa4e4e430007208d6b5cb76f9ca8c279f5 (diff) | |
download | jquery-2c28f229e5eb49f1469fd36ee979529a492f0f42.tar.gz jquery-2c28f229e5eb49f1469fd36ee979529a492f0f42.zip |
fixed offset(coordinates) returns null when no matching elements in jQuery object (fixes ticket #5888)
Diffstat (limited to 'src/offset.js')
-rw-r--r-- | src/offset.js | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/offset.js b/src/offset.js index c3183743b..f80574eea 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, 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, options, i ); }); } + if ( !elem || !elem.ownerDocument ) { + return null; + } + if ( elem === elem.ownerDocument.body ) { return jQuery.offset.bodyOffset( elem ); } |