diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2015-06-16 11:21:58 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2015-06-16 11:21:58 -0400 |
commit | 0e4477c676db0427bb9b0bf39df8631501e62f24 (patch) | |
tree | 25999d25a37da6dc56936cf75a0f4968b1090d46 | |
parent | 40dcc767640c41a4387a343f1ef53ac57ed631c5 (diff) | |
download | jquery-0e4477c676db0427bb9b0bf39df8631501e62f24.tar.gz jquery-0e4477c676db0427bb9b0bf39df8631501e62f24.zip |
Offset: return before getBoundingClientRect to avoid error in IE8-11
-rw-r--r-- | src/offset.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/offset.js b/src/offset.js index fcb7b14de..f0139d5ef 100644 --- a/src/offset.js +++ b/src/offset.js @@ -90,10 +90,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; |