Skip to content

Commit 25e8620

Browse files
committed
Offset: return before getBoundingClientRect to avoid error in IE8-11
1 parent 63f19a9 commit 25e8620

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/offset.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ jQuery.fn.extend({
9595
return;
9696
}
9797

98+
// Support: IE<=11+
99+
// Running getBoundingClientRect on a
100+
// disconnected node in IE throws an error
101+
if ( !elem.getClientRects().length ) {
102+
return { top: 0, left: 0 };
103+
}
104+
98105
rect = elem.getBoundingClientRect();
99106

100-
// Make sure element is not hidden (display: none) or disconnected
101-
if ( rect.width || rect.height || elem.getClientRects().length ) {
107+
// Make sure element is not hidden (display: none)
108+
if ( rect.width || rect.height ) {
102109
doc = elem.ownerDocument;
103110
win = getWindow( doc );
104111
docElem = doc.documentElement;

0 commit comments

Comments
 (0)