]> source.dussan.org Git - jquery.git/commitdiff
Offset: return before getBoundingClientRect to avoid error in IE8-11
authorTimmy Willison <timmywillisn@gmail.com>
Tue, 16 Jun 2015 15:21:58 +0000 (11:21 -0400)
committerTimmy Willison <timmywillisn@gmail.com>
Tue, 16 Jun 2015 15:21:58 +0000 (11:21 -0400)
src/offset.js

index fcb7b14de15835b95d481086fb8162ad4dabf57c..f0139d5effa645e092cdd267ee4e58111d291571 100644 (file)
@@ -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;