Skip to content

Commit

Permalink
Offset: return before getBoundingClientRect to avoid error in IE8-11
Browse files Browse the repository at this point in the history
  • Loading branch information
timmywil committed Jun 16, 2015
1 parent 63f19a9 commit 25e8620
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,17 @@ jQuery.fn.extend({
return;
}

// Support: IE<=11+
// Running getBoundingClientRect on a
// disconnected node in IE throws an error
if ( !elem.getClientRects().length ) {
return { top: 0, left: 0 };
}

rect = elem.getBoundingClientRect();

// Make sure element is not hidden (display: none) or disconnected
if ( rect.width || rect.height || elem.getClientRects().length ) {
// Make sure element is not hidden (display: none)
if ( rect.width || rect.height ) {
doc = elem.ownerDocument;
win = getWindow( doc );
docElem = doc.documentElement;
Expand Down

0 comments on commit 25e8620

Please sign in to comment.