aboutsummaryrefslogtreecommitdiffstats
path: root/src/offset.js
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2015-06-16 11:21:58 -0400
committerTimmy Willison <timmywillisn@gmail.com>2015-06-16 11:24:42 -0400
commit25e8620da9c6e245516d8ac1b0f9ddc896838883 (patch)
tree66d03982203d81bd304219267ceafbcadf3f4e81 /src/offset.js
parent63f19a95b9bfffdc7b8800f89a9def768cc3aebd (diff)
downloadjquery-25e8620da9c6e245516d8ac1b0f9ddc896838883.tar.gz
jquery-25e8620da9c6e245516d8ac1b0f9ddc896838883.zip
Offset: return before getBoundingClientRect to avoid error in IE8-11
Diffstat (limited to 'src/offset.js')
-rw-r--r--src/offset.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/offset.js b/src/offset.js
index d184016e9..bad91e779 100644
--- a/src/offset.js
+++ b/src/offset.js
@@ -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;