Commit
… Fixes #4996.
- Loading branch information
There are no files selected for viewing
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -5,7 +5,7 @@ var rtable = /^t(?:able|d|h)$/i, | ||
|
|
||
if ( "getBoundingClientRect" in document.documentElement ) { | if ( "getBoundingClientRect" in document.documentElement ) { | ||
jQuery.fn.offset = function( options ) { | jQuery.fn.offset = function( options ) { | ||
var elem = this[0]; | var elem = this[0], box; | ||
|
|
||
if ( options ) { | if ( options ) { | ||
return this.each(function( i ) { | return this.each(function( i ) { | ||
|
@@ -21,8 +21,14 @@ if ( "getBoundingClientRect" in document.documentElement ) { | ||
return jQuery.offset.bodyOffset( elem ); | return jQuery.offset.bodyOffset( elem ); | ||
} | } | ||
|
|
||
var box = elem.getBoundingClientRect(), | try { | ||
doc = elem.ownerDocument, | box = elem.getBoundingClientRect(); | ||
|
|||
} catch(e) { | |||
box = { top: elem.offsetTop, left: elem.offsetLeft }; | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jeresig
Author
Member
|
|||
} | |||
|
|||
var doc = elem.ownerDocument, | |||
body = doc.body, | body = doc.body, | ||
docElem = doc.documentElement, | docElem = doc.documentElement, | ||
win = getWindow(doc), | win = getWindow(doc), | ||
|
This may not work as expected as IE6/7 return
-2
foroffsetTop
andoffsetLeft
for disconnected DOM nodes and not0
as the other browsers do