Skip to content

Commit 0e4477c

Browse files
committed
Offset: return before getBoundingClientRect to avoid error in IE8-11
1 parent 40dcc76 commit 0e4477c

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
@@ -90,10 +90,17 @@ jQuery.fn.extend({
9090
return;
9191
}
9292

93+
// Support: IE<=11+
94+
// Running getBoundingClientRect on a
95+
// disconnected node in IE throws an error
96+
if ( !elem.getClientRects().length ) {
97+
return { top: 0, left: 0 };
98+
}
99+
93100
rect = elem.getBoundingClientRect();
94101

95-
// Make sure element is not hidden (display: none) or disconnected
96-
if ( rect.width || rect.height || elem.getClientRects().length ) {
102+
// Make sure element is not hidden (display: none)
103+
if ( rect.width || rect.height ) {
97104
doc = elem.ownerDocument;
98105
win = getWindow( doc );
99106
docElem = doc.documentElement;

0 commit comments

Comments
 (0)